Jump to content
Search Community

Trigger on wrong position (only in Safari & Firefox)

the_gmo test
Moderator Tag

Recommended Posts

I have an element that contains a large image, which pins in the center of the screen (trigger: center center), scrolls the entire image and carries on (see attached Codepen*). On Chrome (and Edge) it is working exactly as intended every time. On Safari and Firefox, it doesn't in most cases. It doesn't pin, and leaves a large space underneath the element.

 

After activating the markers I noticed that it seems the trigger is not set to the parent (the pinned element) in those browsers, but to center of the containing image. Thus way too far below. However, if I resize the browser, even by a pixel, it snaps to the right position and works.

 

Any ideas in which area I could search for the problem if it only works after I resize the browser?

 

I have tried to deactivate ScrollSmoother, I have tried without matchMedia (even though I really need it for this element), the problem remains. 

 

* the Codepen works fine, even in Safari or Firefox. This is just to show what I'm doing and it replicates the code of the site as close as it gets. 

See the Pen QWxvygG by the_gmo (@the_gmo) on CodePen

Link to comment
Share on other sites

Hi,

 

I assume that this is happening on a Mac machine, right? I tested this in Ubuntu 20 and 22 and can't see any issue in the example.

 

I see that the codepen has the latest version of GSAP so that's not the issue. What I'm seeing is that you're not wrapping your content in the suggested setup in the docs:

<div id="smooth-wrapper">
  <div id="smooth-content">
    <!--- ALL YOUR CONTENT HERE --->
  </div>
</div>

Give that a try an let us know how it works. Sorry I can't be of more help but I'm not seeing any issue here.

 

Perhaps other users could chime in and give more feedback.

 

Happy Tweening!

Link to comment
Share on other sites

13 hours ago, the_gmo said:

It doesn't pin, and leaves a large space underneath the element.

But the markers are still correct in your 'real'  version?

 

If it's not happening in Codepen it is probably something else interfering, I would disable everything else and see if the issue still persists. If not enable things one by one to find the culprit. 

 

I also can see nothing wrong in your pens code, maybe the distance variable is calculated weird in Safari and Firefox? (but then I would figure it would also happen in the pen), but you can still try loggin the number to see.  And/or maybe round the numbers? And as @Rodrigo stated, maybe thy wrapping it in the correct elements, that is the only warning I see in the browser "ScrollSmoother needs a valid content element."

 

Hope it helps and happy tweening!

Link to comment
Share on other sites

Thanks for the replies. I didn't really had a chance to take a lot through the day.

 

17 hours ago, Rodrigo said:

 

<div id="smooth-wrapper">
  <div id="smooth-content">
    <!--- ALL YOUR CONTENT HERE --->
  </div>
</div>

Give that a try an let us know how it works. Sorry I can't be of more help but I'm not seeing any issue here.

I just forgot those on the Codepen example, the live site has those wrappers.

 

9 hours ago, mvaneijgen said:

But the markers are still correct in your 'real'  version?

Whenever it doesn't work, the markers are somewhere in the empty space below the element. 

1834382262_Screenshot2022-11-12at19_36_28.thumb.png.40318ff1d2139fa898c1b8599cdf3860.png

 

After a resize a snaps to the right position. The marker is in the correct position and the element works as intended.

14882935_Screenshot2022-11-12at19_38_07.thumb.png.e501548928217852fbb40a8dc33651d4.png

 

I logged the variables, they are the same in both browsers. I tried with rounded numbers, still same. I tried Greensock via cdn, still the same.

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...