jQuery animating scroll top to 0 not working on Windows Phone

Posted by cgoddard on Stack Overflow See other posts from Stack Overflow or by cgoddard
Published on 2013-05-21T23:21:31Z Indexed on 2013/07/03 17:05 UTC
Read the original article Hit count: 667

Filed under:
|
|

I have written a website which has a function that scrolls the users view to the top of the page. The call in question is:

$('html,body').animate({scrollTop:0}, 150, 'swing');

This works fine on all desktop browsers, but on Windows Phone, it only scrolls the user up about 180 pixels, then stops. I have tried replacing the function with:

$('html,body').scrollTop(0);

It snaps to the top on desktops, but it scrolls to the top on the phone. I believe this need for Internet Explorer Mobile to try to smoothly animate the scrolling, and is causing the issue. If this is the case (or if not, could someone correct me), how can I override this function to get the animation to work?

EDIT

Although its not ideal, it does seem to work in a limited capacity, I have replaced the scroll code with this:

$('html,body').animate({scrollTop:0}, 150, 'swing', function() {
    $('html,body').scrollTop(0);
});

But it would be good to know if there is an option to disable the smooth scrolling in Mobile IE programatically.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about windows-phone-8