1 2gsap.registerPlugin(ScrollTrigger); 3 4const lenis = new Lenis({ 5 duration: 1.5, 6 easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)) 7}) 8 9function raf(time) { 10 lenis.raf(time) 11 requestAnimationFrame(raf) 12} 13 14requestAnimationFrame(raf) 15 16 17function animateElementExample() { 18 // Animate Client Logos In 19 // First of all, detect if the block_parent_class is on the page or not. 20 // If it's not, we don't execute the script. 21 const block_parent_class = document.getElementsByClassName( 22 'block_parent_class' 23 ).length > 0; 24 if (block_parent_class) { 25 // Animate Elements In - Trigger when parent element comes into viewport. Example: 26 const animateElementIn = gsap.fromTo("#animate_element_in", 27 { 28 // From 29 y: 100, 30 }, 31 32 { 33 // To 34 y: 0, 35 duration: 1, 36 stagger: 0.1, 37 onComplete: function () { 38 jQuery('#element_parent').addClass('completed_animation'); 39 } 40 }); 41 ScrollTrigger.create({ 42 trigger: "#element_parent", 43 animation: animateElementIn, 44 }); 45 if (ScrollTrigger.isInViewport("#element_parent")) { 46 animateElementIn.progress(1); 47 } 48 } 49} 50jQuery(document).ready(function(){ 51 // Execute GSAP scripts here, in (document).ready(); 52 // animateElementExample(); 53});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.