Jump to content
Search Community

scrollTo offset not working

dwillis test
Moderator Tag

Go to solution Solved by PointC,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi!

I'm using GSAP with ScrollMagic on a one-page site I'm developing. To scroll to a particular section I'm using the scrollTo plugin and it's working great but I need it to have an offset when it scrolls so the heading doesn't scroll under the nav. scrollTo helpfully provides an 'offsetY' property but for some reason it's not working for me. No matter what offset I put in, it scrolls to the same position. There are no console errors though. You can see it not working on the linked codepen demo. Here's the specific line:

TweenMax.to(window, 0.5, {scrollTo: {y: newpos, offsetY:70}});

Any idea what I'm doing wrong?

 

TIA!

 

David

See the Pen woxWxM by anon (@anon) on CodePen

Link to comment
Share on other sites

  • Solution
Hi dwillis :)
 
Looks like you're using older versions of TweenMax and ScrollTo. I switched them to 1.19 in your pen and it worked fine. Just make this adjustment and you should be good to go.
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/plugins/ScrollToPlugin.min.js"></script>

Happy tweening.

:)

  • Like 2
Link to comment
Share on other sites

 

Hi dwillis  :)
 
Looks like you're using older versions of TweenMax and ScrollTo. I switched them to 1.19 in your pen and it worked fine. Just make this adjustment and you should be good to go.
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/plugins/ScrollToPlugin.min.js"></script>

Happy tweening.

:)

 

 

Ah, I hadn't realized. I love an easy fix! Thank you!

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