// Close
closeWindow.addEventListener('click', () =>{
vkInstruct.classList.add(animationClass, animationOut);
vkInstruct.addEventListener('animationend', () => {
vkInstruct.classList.remove(animationClass, animationIn, animationOut);
vkInstruct.style.display = "none";
}, {once: true}); // <- once: true сработает один раз и удалит обработчик
});
const myArray = ["1", "2", "3", "4"];
(async function (array) {
for (item of array) {
await fetch(`https://jsonplaceholder.typicode.com/posts/${item}`)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((error) => console.error(error));
}
})(myArray);
const myArray = ["1", "2", "3", "4"];
myArray.reduce((p, item) => {
return p
.then(() => fetch(`https://jsonplaceholder.typicode.com/posts/${item}`))
.then((response) => response.json())
.then((response) => console.log(response))
.catch((error) => console.error(error));
}, Promise.resolve());
animate
, заменить оригинал клоном и клону задать атрибут begin = performance.now()
.const TARGET_FPMS = 0.06; // 60 / 1000
let lastTime, elapsedMS, deltaTime;
function loop(now) {
requestAnimationFrame(loop);
lastTime = lastTime || now;
elapsedMS = now - lastTime;
lastTime = now;
deltaTime = elapsedMS * TARGET_FPMS;
cube.position.y += 5 * deltaTime;
}
requestAnimationFrame(loop);
window.addEventListener('scroll', onscroll);
function onscroll(event) {