setInterval issue, if i turn on new tap, that can be slower
var rollImg = ["https://media.istockphoto.com/photos/fire-letter-a-of-burning-flame-picture-id844027508?k=6&m=844027508&s=170667a&w=0&h=dt0qXfyejRq_kjs5PqXcMf7Fij_opW7w1kfhfmH6dyQ=",
"https://cdn.leroymerlin.com.br/products/letra_b_11cm_acrilico_preto_kami_acrilicos_89622526_0001_600x600.jpg"];
var layer1Interval = 4000;
var layer2Interval = 5000;
var animationInterval = 1000;
$(function() {
var roll = 1;
function rollFnc () {
setTimeout(function() {
roll++;
if (roll > 2) {
roll = 1;
}
$("#box1").attr("src", rollImg[roll - 1]);
setTimeout(rollFnc, layer1Interval + animationInterval * 1.5);
}, animationInterval / 2);
}
rollFnc();
})
var tl = new TimelineMax({
repeat: -1,
repeatDelay: (layer1Interval / 1000)
});
tl.from(".layer1", animationInterval / 1000, {
scaleX: 0,
transformOrigin: "left",
ease: 'expo.inOut'
});
tl.to(".layer1", animationInterval / 1000, {
scaleX: 0,
transformOrigin: "right",
ease: 'expo.out'
});
Are there any code examples left?
New code examples in category Javascript
-
Javascript 2023-04-21 22:52:36
-
Javascript 2022-03-27 22:25:20 javascript download string as file
-
Javascript 2022-03-27 21:40:22 sort numbers in array javascript
-
Javascript 2022-03-27 21:20:04 compare two arrays and return the difference javascript
-
Javascript 2022-03-27 21:15:02 javascript regex french phone number
-
Javascript 2022-03-27 21:05:03 cypress custom error message
-
Javascript 2022-03-27 21:00:05 create element javascript with id
-
Javascript 2022-03-27 20:40:57 feather icons react
-
Javascript 2022-03-27 20:20:01 how to make graphql request in axios
-
Javascript 2022-03-27 20:15:07 bootstrap validator password and confirm password