Advertisement
jrlopezd

animacionAirPods

Nov 24th, 2022 (edited)
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.86 KB | Gaming | 0 0
  1. var anim;
  2. var elem = document.getElementById('animacionAirPods')
  3. var animData = {
  4.     container: elem,
  5.     renderer: 'canvas',
  6.     loop: false,
  7.     autoplay: false,
  8.     rendererSettings: {
  9.         progressiveLoad: false,
  10.         preserveAspectRatio: 'xMidYMid slice'
  11.     },
  12.     path: 'ENLACE_JSON_AQUI'
  13. };
  14.  
  15. anim = bodymovin.loadAnimation(animData);
  16.  
  17. jQuery(document).ready(function( $ ) {
  18.     $(window).scroll(function() {
  19.         // calculate the percentage the user has scrolled down the page
  20.         var scrollPercent = 100 * $(window).scrollTop() / ($(document).height() - $(window).height());
  21.         console.log(anim.currentRawFrame);
  22.         scrollPercentRounded = Math.round(scrollPercent);
  23.         /*console.log( (scrollPercentRounded / 100) * anim.totalFrames );*/
  24.         anim.goToAndStop( (scrollPercentRounded / 100) * 4000)
  25.     });
  26. });
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement