Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollTo(0) doesn't work #27

Closed
fabien-michel opened this issue Nov 9, 2012 · 4 comments
Closed

ScrollTo(0) doesn't work #27

fabien-michel opened this issue Nov 9, 2012 · 4 comments

Comments

@fabien-michel
Copy link

$(document).scrollTo(0) doesn't work whereas $(document).scrollTo(1) does.

Exemple here : http://jsfiddle.net/VxSfp/

@flesler
Copy link
Owner

flesler commented Nov 19, 2012

The correct way to scroll the window would be:
$(window).scrollTo(0);
or
$.scrollTo(0);

Still I'm trying with document too, on my demo and it works:
http://demos.flesler.com/jquery/scrollTo/

Maybe something is wrong in your implementation?
Make you're using the latest version of scrollTo (1.4.3.1) and preferably and new version of jQuery.

@fabien-michel
Copy link
Author

The demo of the bug on jsfiddle use jquery 1.7.2 and scrollTo 1.4.3. (it bug also with jquery 1.8.2)
The browsers i use to try is Firefox 16 and Chrome 16
Maybe the implementation is wrong, but i don't see where.

@htrex
Copy link

htrex commented Dec 14, 2012

$(window).scrollTo(0); or $.scrollTo(0); works well to scroll to 0.
Otherwise had some headaches with a script that dynamically calculates the scrollTo coordinates and found that
if a negative value is passed to scrollTo it generates a js error, may be it should filter negative values and just scroll to zero.

Solved with something like this:

var newY = Math.max(targetY, 0);
$(window).scrollTo(newY);

@flesler
Copy link
Owner

flesler commented Dec 14, 2012

Actually you're right, just reported the bug on #30 and closing this because it seems to be working.

@flesler flesler closed this as completed Dec 14, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants