Answer the question
In order to leave comments, you need to log in
How to execute a script with a delay?
There are two simple scripts that run css animation. The task is to modify both codes so that they start executing with a delay of one second.
$( document ).ready(function() {
$('.device-arrow15').addClass("slideUp");
});
$(window).scroll(function() {
$('#example-13').each(function(){
var imagePos = $(this).offset().top;
var topOfWindow = $(window).scrollTop();
if (imagePos < topOfWindow+600) {
$('.device-arrow13').addClass("slideLeft");
}
});
});
Answer the question
In order to leave comments, you need to log in
Solution for the first script:
$( document ).ready(function() {
setTimeout(function() {
$('.device-arrow14').addClass("slideUp");
}, 1000);
});
$(window).scroll(function() {
setTimeout(function() {
$('#example-13').each(function(){
var imagePos = $(this).offset().top;
var topOfWindow = $(window).scrollTop();
if (imagePos < topOfWindow+600) {
$('.device-arrow13').addClass("slideLeft");
}
});
}, 1000);
});
In your example, they will appear at the same time, so that this happens with a delay, you can do this
setTimeout(function () {
// Анимация для 1, когда она закончится, начнется для 2
setTimeout(function () {
// // Анимация для 2, когда она закончится, начнется для 3, и т д
}, 1000);
}, 1000);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question