У меня есть сценарий при использовании библиотеки typed.js . Я пытаюсь вывести 3 строки + 1 последнюю. Код работает, выводя 2 строки + 1 последнюю. При попытке исправить это код зависает без отправки сообщения об ошибке.
Эта версия кода работает без ошибок. Выводит 2 линии + 1.
const lineNumber = app.id !== 2 ? ++app.id : (app.id += 2);
setTimeout(() => {
const typed = new Typed(`#line${lineNumber}`, {
strings: text,
typeSpeed: speed,
onComplete: callback,
});
}, timeout);
};
$.getJSON(ipgeolocation, (data) => {
writeLine(["line1"], 30, () => {
if (app.skippedIntro) return;
clearCursor();
const usernames = ['user', 'dude'];
const ip = data.ip ? data.ip : usernames[Math.floor(Math.random() * usernames.length)];
const country = data.country_name ? data.country_name : 'your country';
writeLine([`line2`], 30, 500, () => {
if (app.skippedIntro) return;
clearCursor();
writeLine([`start`], 120, 500, () => {
timeouts.push(
setTimeout(() => {
if (app.skippedIntro) return;
clearCursor();
setTimeout(() => {
skipIntro();
}, 500);
}, 1000)
);
});
});
});
});
Эта версия кода не работает. Согласно идее, он должен выводить 3 строки + 1.
const lineNumber = app.id !== 2 ? ++app.id : (app.id += 2);
setTimeout(() => {
const typed = new Typed(`#line${lineNumber}`, {
strings: text,
typeSpeed: speed,
onComplete: callback,
});
}, timeout);
};
$.getJSON(ipgeolocation, (data) => {
writeLine(["line1"], 30, () => {
if (app.skippedIntro) return;
clearCursor();
const usernames = ['user', 'dude'];
const ip = data.ip ? data.ip : usernames[Math.floor(Math.random() * usernames.length)];
const country = data.country_name ? data.country_name : 'your country';
writeLine([`line2`], 30, 500, () => {
if (app.skippedIntro) return;
clearCursor();
writeLine([`line3`], 30, 500, () => {
if (app.skippedIntro) return;
clearCursor();
writeLine([`start`], 120, 500, () => {
timeouts.push(
setTimeout(() => {
if (app.skippedIntro) return;
clearCursor();
setTimeout(() => {
skipIntro();
}, 500);
}, 1000)
);
});
});
});
});
});