Share Posted March 9, 2021 I've been trying to implement Gsap with ionic & angular and it seems like just don't work https://lampdigitalcol.web.app/666 https://stackblitz.com/edit/gsap-scroll-trigger?file=src/app/app.component.html Does anyone have any idea of why is this happening? Link to comment Share on other sites More sharing options...
Author Share Posted March 9, 2021 19 hours ago, luisnull666 said: I've been trying to implement Gsap with ionic & angular and it seems like just don't work https://lampdigitalcol.web.app/666 angular-scroll-trigger-sryprn - StackBlitz Does anyone have any idea of why is this happening? Both of them has the same code Link to comment Share on other sites More sharing options...
Share Posted March 9, 2021 I'm completely unfamiliar with Ionic, sorry, but this looks very strange to me in your ScrollTrigger settings: start: "top top", end: "bottom bottom" Did you realize that's telling it to START when the top of the box hits the top of the viewport...and end when the bottom of the box hits the bottom of the viewport? In your example, that doesn't really make any sense because the box is smaller than the viewport, so by the time it starts (top hits the top), the bottom is already way past the bottom. See what I mean? Perhaps you meant: end: "bottom top" ? But as for Ionic, you'd have to provide a minimal demo. From what I can tell, your Stackblitz link doesn't use Ionic, right? 3 Link to comment Share on other sites More sharing options...
Share Posted March 9, 2021 15 hours ago, luisnull666 said: Does anyone have any idea of why is this happening? Ionic uses a nested container for scrolling, so you will probably have to use a reference to that container for the trigger. https://greensock.com/docs/v3/Plugins/ScrollTrigger/trigger 3 Link to comment Share on other sites More sharing options...
Share Posted March 9, 2021 1 hour ago, OSUblake said: Ionic uses a nested container for scrolling, so you will probably have to use a reference to that container for the trigger. https://greensock.com/docs/v3/Plugins/ScrollTrigger/trigger Yep, or perhaps the "scroller" if that's the thing that's doing the scrolling: https://greensock.com/docs/v3/Plugins/ScrollTrigger/scroller Oh, and in my earlier message I said you may have meant end: "bottom top" but actually if you wanted to have the box fade in when it enters the viewport, you'd set the start: "top bottom" and then if you want it to fade out at the top, you could do end: "top top" 1 1 Link to comment Share on other sites More sharing options...
Author Share Posted March 9, 2021 3 hours ago, OSUblake said: Ionic uses a nested container for scrolling, so you will probably have to use a reference to that container for the trigger. https://greensock.com/docs/v3/Plugins/ScrollTrigger/trigger When you say that i need to use a reference to the container for the trigger you mean that i need to specify a component and give it the values of a trigger? https://stackblitz.com/edit/angular-ionic-gsap?file=src/app/pages/index/index.page.ts Would please help me?, here is a stackblitz with Anguar, ionic and the example with gsap scroll trigger & the issue. Link to comment Share on other sites More sharing options...
Share Posted March 9, 2021 You should probably use the scroller property instead. https://greensock.com/docs/v3/Plugins/ScrollTrigger/scroller Just need to figure out which element is doing the scrolling. 1 Link to comment Share on other sites More sharing options...
Author Share Posted March 9, 2021 1 hour ago, OSUblake said: You should probably use the scroller property instead. https://greensock.com/docs/v3/Plugins/ScrollTrigger/scroller Just need to figure out which element is doing the scrolling. Sorry, but i don't get it... who should have the trigger? ion-app?, the issue that i'm seeing is that the elements inside the container are not getting the triggers as it should be... https://stackblitz.com/edit/angular-ionic-gsap?file=src/app/pages/index/index.page.html Link to comment Share on other sites More sharing options...
Share Posted March 10, 2021 @luisnull666 I'm completely unfamiliar with Ionic - how would you reference the element that has the scrollbar that would move in that context (the scroller)? I assume there's something with Ionic that delays "hydration" and won't allow you to reference those elements until a certain lifecycle event/callback is fired(?) The point is that you should wait until those elements actually exist, and then create your ScrollTrigger and set its "scroller" property to that element (the one that has the scrollbar on it). 1 Link to comment Share on other sites More sharing options...
Share Posted April 12, 2021 Did you find a solution? From what I understand of ionic we have at least 2 problems. 1) it uses a sort of virtual dom and the main.inner-scoll element is rendered inside the virtual dom. 2) the element to whom the scroll is applied is the ion-content element An almost working solution is to pass the event detail to a class property In the ion-content tag we can use [scrollEvents]="true" and (ionScroll)="logScrolling($event)" to pass to the method the scroll event. logScrolling(ev){ this.scroll = ev.detail } then we have a getter function to retrieve the value getScroll(){ if(!this.scroll){ return {scrollTop:0} } return this.scroll } finally we can use ScrollTrigger.scrollerProxy in this way initAnimations(){ gsap.registerPlugin(ScrollTrigger); const scrollProxy = document.getElementsByTagName('ion-content').item(0) const self = this ScrollTrigger.scrollerProxy(scrollProxy, { scrollTop(value){ return self.getScroll().scrollTop ; // getter }, getBoundingClientRect() { return {top: 0, left: 0, width: window.innerWidth, height: window.innerHeight}; } }); gsap.to('#imgAnimate',{ scrollTrigger:{ trigger:'#imgAnimate', start:"top center", markers:true, toggleActions:"restart pause reverse pause", scroller:scrollProxy }, rotation:360, duration:3 }) } the initAnimations function needs some work but at least is working. Sorry for my english I hope this could be of some help. 1 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