Animation on scroll
-
Hi,
I’ve been trying to figure this out for a while but I can’t seem to get it to work. On a forum I found this solution for a normal website. Adding this to wordpress doesn’t work. Can someone help me out and put me in the right direction? I’ve commented out two sections which I think need replacement? Thanks in advance.
var anim; var elem = document.getElementById('bodymovin') var animData = { container: elem, // WHAT DO I NEED TO PUT HERE? renderer: 'svg', loop: false, autoplay: false, rendererSettings: { progressiveLoad:false, preserveAspectRatio: 'xMidYMid slice' }, path: 'data.json' // WHAT DO I NEED TO PUT HERE? }; anim = bodymovin.loadAnimation(animData); $(window).scroll(function() { // calculate the percentage the user has scrolled down the page var scrollPercent = 100 * $(window).scrollTop() / ($(document).height() - $(window).height()); console.log(anim.currentRawFrame); scrollPercentRounded = Math.round(scrollPercent); /*console.log( (scrollPercentRounded / 100) * anim.totalFrames );*/ anim.goToAndStop( (scrollPercentRounded / 100) * 4000) });
- The topic ‘Animation on scroll’ is closed to new replies.