testerhs567 Posted March 24, 2024 Posted March 24, 2024 Hi everyone, I'm experiencing an issue with my animation. I've searched through existing topics, but couldn't find a solution that matches my problem. To provide some context, I've created a dynamic page for displaying project details. It consists of a description section on the left and an image section on the right. The description is scrollable, and the image changes based on the current description. The issue like i start from project/1 i show all there descriptions all good but when i go to the project/2 or project/^n the scroll still in the register or some where that affect to my animation (the scroll affect to the first image because the scroll still ) ,However, everything works fine if I refresh the page like what i want , So, I'm looking for a solution to reset the ScrollTrigger and resizing functionality dynamically. (methods or props in the useGSAP) Thanks for your help, and I apologize for the lengthy explanation. I just wanted to ensure the context is clear. gsap.registerPlugin(ScrollTrigger); const workInfoItemsRef = useRef(); let imageRefs = useRef([]); const ParrentRef = useRef(); useGSAP( () => { // initialise the imageRefs if ( workInfoItemsRef.current && imageRefs.current.length > 0 && NumberOfFeature > 1 ) { // N2aficti ZIndex directly lrefs: imageRefs.current.forEach((item, index) => { item.style.zIndex = imageRefs.current.length - index; }); // nInitialiser clip-path b refs: gsap.set(imageRefs.current, { clipPath: function () { return "inset(0px)"; }, }); // nCriyi l'animation : const animation = gsap.to( imageRefs.current, // fiha ta last child ! rd lball { clipPath: function (i) { return i != imageRefs.current.length - 1 ? "inset(0px 0px 100% 0px)" : "inset(0px)"; }, stagger: 2, ease: "none", } ); // nCriyi ScrollTrigger l Parrent ref: ScrollTrigger.create({ trigger: ParrentRef.current, start: "top bottom", // markers:true, animation: animation, scrub: 1, }); } }, { dependencies: [CurrentProject], scope: ParrentRef, revertOnUpdate: true } );
GSAP Helper Posted March 25, 2024 Posted March 25, 2024 Without a minimal demo, it's very difficult to troubleshoot; the issue could be caused by CSS, markup, a third party library, a 3rd party script, etc. Would you please provide a very simple CodePen or Stackblitz that illustrates the issue? Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependencies as possible. Start minimal and then incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, at least we have a reduced test case which greatly increases your chances of getting a relevant answer. See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen. that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo: Using a framework/library like React, Vue, Next, etc.? CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: React (please read this article!) Next Svelte Sveltekit Vue Nuxt Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. ✅
GreenSock Posted March 25, 2024 Posted March 25, 2024 Yeah, a minimal demo will go a very long way toward getting you a solid answer, but it kinda sounds like maybe you are lazy-loading images such that they don't trigger the window's "load" event when they're done (which would fire the ScrollTrigger.refresh()). If that's the case, you need to either call ScrollTrigger.refresh() once your page layout is settled (after images finish loading), or explicitly set the width/height of your images so that there is no shifting of the layout when they finish loading.
testerhs567 Posted March 26, 2024 Author Posted March 26, 2024 19 hours ago, GSAP Helper said: Without a minimal demo, it's very difficult to troubleshoot; the issue could be caused by CSS, markup, a third party library, a 3rd party script, etc. Would you please provide a very simple CodePen or Stackblitz that illustrates the issue? Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependencies as possible. Start minimal and then incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, at least we have a reduced test case which greatly increases your chances of getting a relevant answer. that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo: Using a framework/library like React, Vue, Next, etc.? CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: React (please read this article!) Next Svelte Sveltekit Vue Nuxt Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. ✅ Thanks , for the demo is hard to implement it as basic , but just the response i'm look for is there's some methods for reregister the plugin and i will because the issue happen just when i go to other /n project soo that refresh or whatever if already built in , i think will solve Thanks for your time
testerhs567 Posted March 26, 2024 Author Posted March 26, 2024 9 hours ago, GreenSock said: Yeah, a minimal demo will go a very long way toward getting you a solid answer, but it kinda sounds like maybe you are lazy-loading images such that they don't trigger the window's "load" event when they're done (which would fire the ScrollTrigger.refresh()). If that's the case, you need to either call ScrollTrigger.refresh() once your page layout is settled (after images finish loading), or explicitly set the width/height of your images so that there is no shifting of the layout when they finish loading. i don't think so , because if the cuz's the lazy loading it's will not work in first visit , but it's work like charm , i'll try other approaches to solve it thanks
GreenSock Posted March 26, 2024 Posted March 26, 2024 14 hours ago, testerhs567 said: i don't think so , because if the cuz's the lazy loading it's will not work in first visit , but it's work like charm , i'll try other approaches to solve it thanks Not if you're doing some kind of routing. The first time the page loads, the window will fire the "load" event after the images load (assuming no lazy loading), but then if you're doing routing in React to go to other "pages" (content) without the browser actually loading an entirely new URL, then the "load" event doesn't fire, thus ScrollTrigger.refresh() isn't automatically called. See what I mean? Again, a minimal demo will go a very long way toward getting you a solid answer. I was totally just guessing here.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now