: CSS3 animation to start only when page is scrolled to the right place I want to show an CSS3 animation with a delay, but it is below the fold of the page, meaning, that animation may start
I want to show an CSS3 animation with a delay, but it is below the fold of the page, meaning, that animation may start and end before user scrolls to the area where it should perform.
How can I set up to start the animation when a container DIV gets visible for the user when he scrolls down to this DIV?
More posts by @Gonzalez347
1 Comments
Sorted by latest first Latest Oldest Best
You can use jQuery (or make it plain JS) to add a class when a certain point has been reached.
var classHadBeenAdded = false;
$(document).on('scroll', function(){
if( !classHadBeenAdded && $(document).scrollTop() < foldValue ){
$('#element').addClass('ClassWithAnimation');
classHadBeenAdded = true; // save change so it doesnt double.
}
});
You might want to add a dethrottle to it to prevent the number of calls jamming your browser.
Another method is a variant, make transition-delay something very high, and change that value with JS upon the triggerpoint.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.