*'); var listItems = slides[index].querySelectorAll('.custom-field-stuff-list li'); slideAnimation = gsap.to(proxy, { x: x, duration: slideDuration, onStart: function () { gsap.set(slideContent, { y: 30, opacity: 0 }); gsap.set(listItems, { y: 30, opacity: 0 }); }, onUpdate: updateProgress, onComplete: function () { gsap.to(slideContent, { y: 0, opacity: 1, stagger: 0.3 }); gsap.to(listItems, { y: 0, opacity: 1, stagger: 0.3 }); } }); var slideInfo = slides[index].querySelector('.slide-info'); var title = slides[index].querySelector('h1'); var subtitle = slides[index].querySelector('h3'); gsap.to(slideInfo, { opacity: 1, x: 0, y: 0, duration: slideDuration, onComplete: function () { gsap.to(title, { opacity: 1, y: 0, duration: slideDuration }); gsap.to(subtitle, { opacity: 1, y: 0, duration: slideDuration, onComplete: animateListItems }); } }); } function animateListItems() { var listItems = slides[index].querySelectorAll('.custom-field-stuff-list li'); gsap.to(listItems, { opacity: 1, x: 0, y: 0, duration: slideDuration, stagger: 0.3 }); } //wait until images, links, fonts, stylesheets, and js is loaded window.addEventListener("load", function(e){ var slideDelay = 8; var slideDuration = 0.5; var snapX; var slides = document.querySelectorAll(".slide"); var progressWrap = gsap.utils.wrap(0, 1); var indexWrap = gsap.utils.wrap(0, slides.length); var numSlides = slides.length; gsap.set(slides, { xPercent: i => i * 100 }); var wrap = gsap.utils.wrap(-100, (numSlides - 1) * 100); var timer = gsap.delayedCall(slideDelay, autoPlay); var animation = gsap.to(slides, { xPercent: "+=" + (numSlides * 100), duration: 1, ease: "none", paused: true, repeat: -1, modifiers: { xPercent: wrap } }); var proxy = document.createElement("div"); var slideAnimation = gsap.to({}, {}); var slideWidth = 0; var wrapWidth = 0; resize(); /*var draggable = new Draggable(proxy, { trigger: ".slides-container", onPress: updateDraggable, onDrag: updateProgress, onThrowUpdate: updateProgress, snap: { x: snapX } });*/ window.addEventListener("resize", resize); /* function updateDraggable() { timer.restart(true); slideAnimation.kill(); this.update(); }*/ function animateSlides(direction) { timer.restart(true); slideAnimation.kill(); var x = snapX(gsap.getProperty(proxy, "x") + direction * slideWidth); var index = indexWrap(-x / slideWidth); var slideContent = slides[index].querySelectorAll('.text-wrap > *'); slideAnimation = gsap.to(proxy, { x: x, duration: slideDuration, onStart: function() { gsap.set(slideContent, { y: 30, opacity: 0 }); }, onUpdate: updateProgress, onComplete: function() { gsap.to(slideContent, { y: 0, opacity: 1, stagger: 0.3 }); } }); } function autoPlay() { /* if (draggable.isPressed || draggable.isDragging || draggable.isThrowing) { timer.restart(true); } else {*/ animateSlides(-1); //} } function updateProgress() { animation.progress(progressWrap(gsap.getProperty(proxy, "x") / wrapWidth)); } function resize() { var norm = (gsap.getProperty(proxy, "x") / wrapWidth) || 0; slideWidth = slides[0].offsetWidth; wrapWidth = slideWidth * numSlides; snapX = gsap.utils.snap(slideWidth); gsap.set(proxy, { x: norm * wrapWidth }); animateSlides(0); slideAnimation.progress(1); } window.addEventListener("load", function (e) { var listItems = document.querySelectorAll('.custom-field-stuff-list li'); gsap.set(listItems, { opacity: 0, x: -50, y: 50 }); gsap.to(listItems, { opacity: 1, x: 0, y: 0, duration: slideDuration, stagger: 0.3, delay: slideDuration }); }, false); }, false);});