PEgaz Posted April 12, 2023 Share Posted April 12, 2023 I've prepared a small video with strange behaviour. Code is written in: "gsap": "^3.11.4", "next": "^13.2.4", I made a div red to be better visible. I want to put later some animation to that form elements, but I have problem with basics, because turning on PIN completely makes it unpredictable. As you will see on video when "pin" in scrollTrigger is off, everything works normally, "start" and "end", "scrollStart", "scrollend" markers are on place, whatever/however/in_what_speed I scroll. When I turn PIN on, "start" and "end" becomes unpredictable, it stops in different places whenever I make a break in scrolling and it snaps to different places and div with form jumps sometimes from place to place, sometimes shows only part of itself ... animation effect: useLayoutEffect(() => { let mm = gsap.matchMedia(); mm.add("(max-width: 768px)", () => { const tl = gsap.timeline({ scrollTrigger: { trigger: contactFormRef.current, markers: true, pin: true, invalidateOnRefresh: true, }, }); }); mm.add("(min-width: 769px) and (max-width: 1223px)", () => { const tl = gsap.timeline({ scrollTrigger: { trigger: contactFormRef.current, markers: true, pin: true, invalidateOnRefresh: true, }, }); }); mm.add("(min-width: 1224px)", () => { const tl = gsap.timeline({ scrollTrigger: { trigger: contactFormRef.current, markers: true, pin: true, invalidateOnRefresh: true, }, }); }); //clear and revert return () => { mm.revert(); }; }, []); jsx looks differently in original - but the same behaviour is noticable with plain HTML like: return <div className="w-full h-full bg-red-700" ref={contactFormRef}></div>; Please help if possible. PEgaz Link to comment Share on other sites More sharing options...
GSAP Helper Posted April 12, 2023 Share Posted April 12, 2023 It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer. Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo: See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen If you're using something like React/Next/Vue/Nuxt or some other framework, you may find StackBlitz easier to use. We have a series of collections with different templates for you to get started on these different frameworks: React/Next/Vue/Nuxt. Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. Link to comment Share on other sites More sharing options...
PEgaz Posted April 13, 2023 Author Share Posted April 13, 2023 Thank you for your answer. Destilating it is so pritty hard, I just thought you may had an instant/obvious idea/solution when you saw it because it happened to somebody else/somewhere. If not ... I will have to cut elements one by one to see where the bug lies. reagards, PEgaz Link to comment Share on other sites More sharing options...
Rodrigo Posted April 13, 2023 Share Posted April 13, 2023 Hi, Unfortunately a small code snippet and a video doesn't really helps us to resolve something, specially considering the fact that there are no errors in that code. We ask for a minimal demo in order to get a better idea of what could be the issue and also allows us to edit the code and find the problems. Indeed the route you're taking of removing elements one by one until the issue is gone, is the best alternative in this cases, not the most fun route but sometimes the best one. Happy Tweening! Link to comment Share on other sites More sharing options...
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