Jump to content
Search Community

alonK

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by alonK

  1. Another issue that you can see in the demo is when the user start to scroll before the first animation is done. It meeses up the scrolltrigger tl for the opacity
  2. Thanks again for this awesome plugin, I'm trying to combine 2 animations, Onload text change opacity from 0 to 1 Onscroll text change opacity from 1 to 0 In my local dev site the opacity jumps when you start to scroll with no ease or scrub, I guess the 2 timelines are effecting each other. I tried to create the error on a codepen and could not, it seem to work fine in the codepen, but you can see what I'm trying to do. I'm looking for a way to work correctly with 2 timeline on the same element on load and on scroll not effecting each other, Thanks for the help! https://codepen.io/Aloillu/pen/LYqdZmK
  3. Hi All, Thank you for this amazing plugin; I absolutely love it! I'm encountering an issue with one of the animations I'm trying to create. On my website, I have a video that plays on load. As the video is nearing its end, I have set up an animation for a text and a scroll button to appear. Additionally, I'm trying to implement some animations with ScrollTrigger for this text and button. However, I'm facing a couple of challenges: The duration setting for the animations seems to have no effect. The animations are not working in reverse when scrolling up. Below is the code for this section. I would greatly appreciate any assistance or insights in resolving these issues. Thank you in advance for your help! function createHpHero() { const text = document.querySelector('.video-container__textbox'); let lines = text.querySelectorAll('.line'); let scroll = document.querySelector('.scroll'); // Play the video immediately when this function is called hpVideo.play(); // Time in seconds before the video ends to start the text animation const timeBeforeEnd = 0.6; function updateTime() { const timeLeft = hpVideo.duration - hpVideo.currentTime; if (timeLeft <= timeBeforeEnd) { // Trigger the text animation and remove the event listener animateText(); hpVideo.removeEventListener('timeupdate', updateTime); } } hpVideo.addEventListener('timeupdate', updateTime); function animateText() { const textTl = gsap.timeline(); textTl.to(text, {autoAlpha: 1}) .to(scroll, {autoAlpha: 1, y: -20}); } const tl = gsap.timeline({ scrollTrigger: { trigger: '.hero-wrap', start: "top top", end: "bottom top", pinSpacing: false, pin: true, scrub: true, markers: true } }) lines.forEach((line, index) => { tl.to(line, { backgroundImage: "linear-gradient(90deg, var(--left) 0%, var(--left) 100%, var(--right) 100%)", duration: 1 }, ">"); }) tl.to(text, { autoAlpha: 0, duration: 1 }) .to(scroll, { autoAlpha: 0, duration: 2 }); }
  4. Hello everyone, I'm working on a project where I'd like to create a layered pinning effect for multiple sections. The goal is to offer a unique scroll experience by showing a "preview" of the next section's header as a sticky footer at the bottom of the current section. As users scroll down, this sticky footer should provide a glimpse of what's coming next. The challenge I'm facing is with the transition from one section to another. When the user reaches the bottom of the current section's content, the sticky footer (preview header of the next section) should unstick, and the next section should then become the primary focus. This next section would then also have its own sticky footer showing a preview of the subsequent section, and so on. I have found solutions for pinned section from bottom like here - https://codepen.io/GreenSock/pen/BaowPwo but not sure how to face the next section preview. Does anyone have experience creating this kind of layered, pinned sections with GSAP and ScrollTrigger? Any guidance or code examples would be extremely appreciated. Thank you in advance for your help!
  5. I have a long page with multiple scroll based simple animations, some of them use the same class name to run different places. At some point it seems the trigger position gets off for all the page and animations at the bottom of the screen are happening in the wrong place, If I open console in the browser the animations are back at the correct position. (function () { gsap.registerPlugin(ScrollTrigger); gsap.defaults({ease: "power4.out"}); ScrollTrigger.matchMedia({ // desktop "(min-width: 800px)": function () { mySplitText = new SplitText(".corona-hero-section h2", {type: "words,chars"}); chars = mySplitText.chars; //an array of all the divs that wrap each character gsap.set(".corona-hero-section h2", {perspective: 400}); var tl = gsap.timeline(); tl .from(".logo", {duration: 2, autoAlpha: 0, y: -60, stagger: 0.3}, 1) .from(chars, { duration: 0.8, opacity: 0, scale: 0, y: 80, rotationX: 180, transformOrigin: "0% 50% -50", ease: "back", stagger: 0.01 }, "+=0"); tl.restart(); scheneChange(5, 140, '.viewer', '.scene', false, 'bottom bottom'); scheneChange(4, 138, '.viewer2', '.scene2', false, 'bottom bottom'); scheneChange(1, 122, '.viewer4', '.scene4', false, 'bottom bottom'); scheneChange(3, 146, '.viewer5', '.scene5', false, 'bottom bottom'); scheneChange(2, 139, '.viewer6', '.scene6', false, 'bottom bottom'); animateImageReveal(); animateStaggerIcons('.icon-list', '.icon-list__item'); animateStaggerIcons('.icon-num', '.icon-num__item'); animateStaggerIcons('.icon-top', '.icon-top__item'); aminateStaggerLi('.map-wrap__item'); aminateStaggerLi('.program-list-wrap li'); }, // mobile "(max-width: 799px)": function () { // Icons and text animation gsap.utils.toArray('.icon-list__item').forEach((section) => { const tls = gsap.timeline({ scrollTrigger: { trigger: section, scrub: true, start: "top center", // markers: true, end: "+=20%", }, }); const delay = 0.5; const textIcon = section.querySelectorAll(".icon-list__icon"); const textTitle = section.querySelectorAll(".icon-list__title"); const textText = section.querySelector(".icon-list__text"); const textNum = section.querySelector(".icon-list__num"); tls .from(textNum, {duration: 3, autoAlpha: 0, y: -60, stagger: delay}, 0) .from(textIcon, {duration: 1, autoAlpha: 0, y: -60, stagger: delay}, 0.3) .from(textTitle, {duration: 1, autoAlpha: 0, y: -60, stagger: delay}, 0.6) .from(textText, {duration: 1, autoAlpha: 0, y: -60, stagger: delay}, 0.9) }); scheneChange(5, 140, '.viewer', '.scene'); scheneChange(4, 138, '.viewer2', '.scene2'); scheneChange(1, 122, '.viewer4', '.scene4', false); scheneChange(3, 146, '.viewer5', '.scene5'); scheneChange(2, 139, '.viewer6', '.scene6', false); scheneImageReveal(); animateIconNum(); scheneChange(1, 163.5, '.viewer3', '.scene3'); }, "all": function () { animateTitleSection(); morphImg('.scene3'); } }); function scheneChange(frames, offset, classToAnimate, action, pin = true, start = "center center") { var frame_count = frames, offset_value = offset; gsap.to(classToAnimate, { backgroundPosition: (-offset_value * frame_count * 2) + "px 50%", ease: "steps(" + frame_count + ")", // use a stepped ease for the sprite sheet scrollTrigger: { trigger: action, start: start, end: "+=" + (frame_count * offset_value), pin: pin, // markers: true, scrub: true, } }); } function morphImg(trigger) { const tls3 = gsap.timeline({ scrollTrigger: { trigger: trigger, scrub: true, start: "top center", // markers: true, end: "+=40%", }, }); tls3 .to('#inIsrael', {duration: 2, fill: "#9191a0", morphSVG: "#inMaoz"}, 0) .to('#israelText', {duration: 2, morphSVG: "#maozText"}, 0) .to('#israelUnderText', {duration: 2, morphSVG: "#maozUnderText"}, 0.2) } function animateIconNum() { const sections = gsap.utils.toArray('.icon-num__item'); sections.forEach((section) => { const tls = gsap.timeline({ scrollTrigger: { trigger: section, scrub: true, start: "top center", // markers: true, end: "+=20%", }, }); const delay = 0.5; const textIcon = section.querySelectorAll(".icon-num__icon"); const textTitle = section.querySelectorAll(".icon-num__title"); const textText = section.querySelector(".icon-num__text"); // const textNum = section.querySelector(".icon-list__num"); tls .from(textText, {duration: 3, autoAlpha: 0, y: -60, stagger: delay}, 0) .from(textIcon, {duration: 1, autoAlpha: 0, y: -60, stagger: delay}, 0.3) .from(textTitle, {duration: 1, autoAlpha: 0, y: -60, stagger: delay}, 0.6) // .from(textText, {duration: 1, autoAlpha: 0, y: -60, stagger: delay}, 0.9) }); } function animateTitleSection() { const sections = gsap.utils.toArray(".corona-header"); sections.forEach((section) => { const splitTimeline = gsap.timeline({ scrollTrigger: { trigger: section, scrub: true, end: "+=70%", // onToggle: self => gsap.to(".split-text", {opacity: self.isActive ? 1 : 0}), toggleActions: "restart pause restart none", //markers: true } }); const split = new SplitText(section); splitTimeline .to(section, {duration: 1, backgroundColor: '#fff', ease: "none"}, 0) .to(section, {duration: 1, backgroundColor: '#222241', ease: "none"}, 1) .from(split.chars, { duration: 2, opacity: 0, x: "random(-500, 500)", y: "random(-500, 500)", z: "random(-500, 500)", scale: .1, yoyo: true, stagger: 0.02 }); }); } function animateImageReveal() { let revealContainers = gsap.utils.toArray(".reveal"); revealContainers.forEach((container) => { let tlImage = gsap.timeline({ scrollTrigger: { trigger: container, scrub: true, start: "top 100%", end: "bottom 70%", } }); tlImage.from(container, {duration: 0.3, autoAlpha: 0, y: -60, stagger: 0.3}, 1); }); } function scheneImageReveal() { let revealContainers = gsap.utils.toArray(".reveal"); revealContainers.forEach((container) => { let image = container.querySelector('img'); let tlImage = gsap.timeline({ scrollTrigger: { trigger: container, start: "20% 70%", toggleActions: "restart none none reset", } }); tlImage.set(container, {autoAlpha: 1}); tlImage.from(container, 1.5, { xPercent: -100, ease: Power2.out }); tlImage.from(image, 1.5, { xPercent: 100, // scale: 0.7, delay: -1.5, ease: Power2.out }); }); } function aminateStaggerLi(trigger) { gsap.set(trigger, {y: 100}); ScrollTrigger.batch(trigger, { onEnter: batch => gsap.to(batch, {opacity: 1, y: 0, stagger: {each: 0.15, grid: [1, 3]}, overwrite: true}), onLeave: batch => gsap.set(batch, {opacity: 0, y: -100, overwrite: true}), onEnterBack: batch => gsap.to(batch, {opacity: 1, y: 0, stagger: 0.15, overwrite: true}), onLeaveBack: batch => gsap.set(batch, {opacity: 0, y: 100, overwrite: true}) }); ScrollTrigger.addEventListener("refreshInit", () => gsap.set(trigger, {y: 0})); } function animateStaggerIcons(list, listItem) { gsap.utils.toArray(list).forEach(section => { const elems = section.querySelectorAll(listItem); // Set things up gsap.set(elems, {y: 50, opacity: 0}); ScrollTrigger.create({ trigger: section, start: 'top 60%', onEnter: () => gsap.to(elems, { y: 0, opacity: 1, duration: 1, stagger: 0.2, delay: 0.3, ease: 'power3.out', overwrite: 'auto' }), onLeaveBack: () => gsap.to(elems, { y: 50, opacity: 0, duration: 1, stagger: 0.2, delay: 0.3, ease: 'power3.out', overwrite: 'auto' }) }); }) } })();
×
×
  • Create New...