I have the following code, basically runs an animation on click, waits 3000ms, then scrolls down to the next page. Problem is, unless I clear the cache and open a new incognito window, the animation/auto scroll only works once. I want it to work each time the page is refreshed. I'm using Wordpress and the fullpage.js plugin. Cheers!
jQuery:
var delay = 3000; //milliseconds
var timeoutId;
var animationIsFinished = false;
new fullpage('#fullpage', {
onLeave: function(origin, destination, direction){
var curTime = new Date().getTime();
jQuery('.spring');
clearTimeout(timeoutId);
timeoutId = setTimeout(function(){
animationIsFinished = true;
fullpage_api.moveTo(destination.index + 1);
}, delay);
return animationIsFinished;},
HTML:
<script>
let iconSkipForward = document.querySelector('.spring');
let animationSkipForward = bodymovin.loadAnimation({
container: iconSkipForward,
renderer: 'svg',
loop: false,
autoplay: false,
path: "https://assets1.lottiefiles.com/packages/lf20_8cxxpvp0.json"
});
iconSkipForward.addEventListener('click', function() {
animationSkipForward.playSegments([0,86], true);
}, {once : true});
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…