Last active
November 4, 2015 09:46
-
-
Save qassa/98a152eb0dee465047fd to your computer and use it in GitHub Desktop.
Анимация плавно выезжающего элемента страницы с заданным значением таймера
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var element = document.getElementById("im"); | |
var currentPosition = element.offsetTop; //Получаем текущее положение блока, который будет выплывать | |
smoothAnimation = requestAnimationFrame(function anim(time) { | |
currentPosition++; | |
element.style.top = currentPosition +"px"; | |
smoothAnimation = requestAnimationFrame(anim); // The animation would not stop after 1.5 sec if delete smoothAnimation in this line because the fucntion reference changes every time it's called | |
}); | |
setTimeout(function(){ | |
cancelAnimationFrame(smoothAnimation); | |
},1500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment