I am trying to maintain a relatively constant speed when scrolling back to the top of the browser window, depending on how far you are from the top of the page.
So, if you have scrolled through a 500px or 5000px page, I would like to create a function that calculates how long it takes to animate back, while maintaining a constant speed.
var scrollTo = function() { var top = $(window).scrollTop(); var dist = $('.article').offset().top; var speed =
source share