Sukru Posted December 22, 2022 Posted December 22, 2022 Hello, I added lightGallery framework to my gsap project, it works fine, but there is a scroll problem. When I turn off the lightbox, it shifts up and down. How can I prevent this? Can you help me? I guess scroll is not locking See the Pen YzjXZQW?authentication_hash=jVkpoNOKZYdA by pen (@pen) on CodePen.
Rodrigo Posted December 22, 2022 Posted December 22, 2022 Hi, Sorry to hear about the issues you're having but I'm not seeing any shift or jumps when testing that codepen in both chrome and firefox on Ubuntu 20 and 22. Can you be more specific about the OS and browser where you're seeing this behaviour? Finally you're using different versions for the GSAP core (3.10.0) and the plugins (3.11.4). Is worth mentioning that just today GSAP was updated to 3.11.4 which included a few fixes in ScrollTrigger and ScrollSmoother, so you might want to updated those dependencies on your local machine. Let us know if you have more questions. Happy Tweening! 1
Solution akapowl Posted December 22, 2022 Solution Posted December 22, 2022 Hello, I can see the issue described, but as Rodrigo mentioned, you will definitely need to update your GSAP version first; and yes, it looks like it is a problem because you can scroll while the gallery is open, and when it closes it will move back to the position it was before opening (or something along those lines). You will need to find the event working best for you, to toggle ScrollSmoother.paused() at the right time, if you want to disable the scroll while the gallery is open. https://greensock.com/docs/v3/Plugins/ScrollSmoother/paused() Here is a link to the events available with lightgallery: https://www.lightgalleryjs.com/docs/events/ Something like this maybe: See the Pen PoBqpeO by akapowl (@akapowl) on CodePen. EDIT: Also, if you update the lightGallery version you are using to at least version 2.5.0, apparently an option comes available that lets you prevent the resetting of the scroll-position altogether which would likely make the blocking of the scroll unneccessary to begin with. Maybe something you'd want to consider. https://www.lightgalleryjs.com/docs/settings/#resetScrollPosition Quote resetScrollPosition boolean true Reset to previous scrollPosition when lightGallery is closed By default, lightGallery doesn't hide the scrollbar for a smooth opening transition. If a user changes the scroll position, lightGallery resets it to the previous value Minimum lightGallery version required: V2.5.0 3
Fisher666 Posted March 27, 2023 Posted March 27, 2023 Hello! I had sort of a similar problem in Nuxt3 with Lightgallery and ScrollSmoother. Before closing Lightgallery, the page jumped to the top and then scrolled back to the gallery container. This occurred only when opening Lightgallery for the first time (still not acceptable ). ScrollSmoother.paused(true) in Lightgallerys onBeforeOpen hook didn't help, it paused on position 0. What did work was setting smooth() to 0 in onBeforeOpen and setting it back to a desired value in Lightgallerys onBeforeClose hook. But... if the gallery was opend while the page was still moving (smoothing), after closing, it jumped to the point where smoothing would end. I found a workaround to that, I'll post it below since this was the only post about the topic I found and it can help someone in the future. const position = ref(); function beforeOpen() { const smoother = ScrollSmoother.get(); position.value = smoother?.scrollTop(); smoother?.smooth(0); } function beforeClose() { const smoother = ScrollSmoother.get(); smoother?.scrollTop(position.value); ScrollTrigger.refresh(); smoother?.smooth(2); } 1
Akainu Posted August 29, 2025 Posted August 29, 2025 Hey guys, I'm also facing the same issue. When LightGallery is activated, it scrolls to the top on desktop (opposite on mobile), but for temp I have kept this, not sure if it's the right way: Using the latest of LightGallery, GSAP + Masonry Grid galleryEl.addEventListener('lgAfterOpen', (event) => { setTimeout(() => { smoother.scrollTo(event.target, true); }, 1000); })
GSAP Helper Posted August 29, 2025 Posted August 29, 2025 Hi @Akainu and welcome to the GSAP Forums! 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 GSAP as shown in the Install Helper in our Learning Center : 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. ✅
Akainu Posted September 3, 2025 Posted September 3, 2025 On 8/30/2025 at 3:40 AM, GSAP Helper said: Hi @Akainu and welcome to the GSAP Forums! 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 GSAP as shown in the Install Helper in our Learning Center : 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. ✅ Yes, sure, plz give me some time as I'm still working on this project and there are other more important bugs to fix
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