Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

ScrollTo Plugin Updating Scroll position

Recommended Posts

Hi Guys,


I have a page with a CSS animation on entry that slides in some content. I also have a scroll to ID snippet as follows:

var footer = document.getElementById("footer");
var footerTop = footer.offsetTop;
function  gotoFooter()
TweenLite.to(window, 1.5, {scrollTo:(footerTop),  ease:Power4. easeInOut});

...however due to the CSS animation that starts on entry my scrollto is wildly off and in fact just slams into the end of the page with an unseemly stop.


My question is, is there a way to update the new page length for the plugin after my animation finishes (its 2 seconds long).


Thanks for any help, I'm just starting to learn this library so please be gentle :P.

Link to comment
Share on other sites

Welcome to the community!


It's tough to say without seeing things in context (like in a codepen), but I'd venture to guess that you can simply shift your variable declarations into your function so that it waits to calculate the footer.offsetTop until gotoFooter() is actually called. There are other ways to handle it, so if this doesn't help, please just provide a simple codepen demo and we'll do our best to provide an alternate solution. 

  • Like 2
Link to comment
Share on other sites

Hi Jack. Thanks so much for replying and yes you were absolutely right of course. Moving the variable declarations inside the function fixed it perfectly. So simple I kicked myself :P. I'll make sure any future questions come with a codepen to help. Thanks again!

  • Like 1
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.