Jump to content
Search Community

Gsap Trigger location problem with Owl Carousel

S3BASTIAN test
Moderator Tag

Recommended Posts

Hi everyone and thanks in advance!

I had this problem a few months back and now I'm having the same problem again. I use to work with this Owl Carousel for the websites I work with, and when combining the Owl Carousel with Gsap, the Star and End triggers are placed in different locations than they should.

On the websites I made, the Start is located wayyyy downwards. In this example it's upwards. I guess that Gsap is making all the calculations before the images are placed. I thought that with ScrollTrigger.refresh(); it should solve this but I guess it's for another case.

Again, thanks in advance!

Sebastian

See the Pen oNJZNaE by soporo123 (@soporo123) on CodePen

Link to comment
Share on other sites

Hey,

 

just from a quick look, Owl initial css is display: none, when you create your effects, there is no space reserved for your images. That's why it looks like the markers are out of place.

Quote

Instead, ScrollTrigger does the processing up-front to figure out where the start/end points are in the natural document flow.  documentation

 

So you need to make sure you call ScrollTrigger.refresh(); after the CSS changes from owl (it overrides display: none to display: block)  happen.

 

Unfortunately I've never used jQuery so I can't tell you where would be the right place to do that. But putting it inside the ready() method after you initialize your Owl carousel seems to work.
You could also check if there are suitable events provided by Owl, something like "afterInit" that you could listen on.

 

Hope this helps and good luck with your project

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...