jQuery animating scroll top to 0 not working on Windows Phone
- by cgoddard
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.