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