Hi! I am having a problem with the pin feature of the scrollTrigger when using it in angular.
The codepen attached shows the desired (correct) behavior.
When I implement it in angular, somehow, the pin-spacer element keeps recalculating its attributes in an infinite loop and it causes some weird behavior, I can see the animation taking place but it does not execute smoothly, and some of the elements which are inside the trigger div and have pure css animations, lose their animations too, I believe this is happening because the "pin-spacer" div keeps regenerating automatically:
enableScrollTrigger() {
const journey = gsap.timeline().to('.flying', 5, { top: 100 });
ScrollTrigger.create({
animation: journey,
trigger: '.maka-plate',
start: 'top top',
scrub: true,
pin: true,
markers: true
});
}
ngOnInit() {
if (isPlatformBrowser(this.platformId)) {
gsap.registerPlugin(ScrollTrigger);
this.enableScrollTrigger();
}
}
//// HTML
<div class="container px-0 maka-plate">
<h1 class="text-dark text-uppercase text-center text-lg-big mb-5">
SEAMOS CLAROS <br>
<span class="stroked-dark">NO SOMOS CROQUETAS.</span>
</h1>
<img class="floating dizzy" src="/assets/images/floating-1.png" alt="" />
<img class="flying" src="/assets/images/flying.png" alt="" />
<img class="plate mt-4" src="/assets/images/plate.png" alt="" />
<img class="floating closer dizzy inverse" src="/assets/images/floating-2.png" alt="" />
</div>