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.
setTimeout
call outside of the.animate
, it was part of the complete callback argument within.animate
. Seems to work ok, but yes, it is annoying having the delay afterward. A device discovery program (server side) would be nice to include a different script, as long as all the window animation is handled in an independent script – Outsail