requestanimationframe
function animateFunction()
{
//animate stuff
window.requestAnimationFrame(animateFunction);
}
window.requestAnimationFrame(animateFunction);
requestanimationframe
function animateFunction()
{
//animate stuff
window.requestAnimationFrame(animateFunction);
}
window.requestAnimationFrame(animateFunction);
requestAnimationframe
const element = document.getElementById('some-element-you-want-to-animate');
let start, previousTimeStamp;
function step(timestamp) {
if (start === undefined)
start = timestamp;
const elapsed = timestamp - start;
if (previousTimeStamp !== timestamp) {
// Math.min() is used here to make sure the element stops at exactly 200px
const count = Math.min(0.1 * elapsed, 200);
element.style.transform = 'translateX(' + count + 'px)';
}
if (elapsed < 2000) { // Stop the animation after 2 seconds
previousTimeStamp = timestamp
window.requestAnimationFrame(step);
}
}
window.requestAnimationFrame(step);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us