jQuery animating scroll top to 0 not working on Windows Phone -
i have written website has function scrolls users view top of page. call in question is:
$('html,body').animate({scrolltop:0}, 150, 'swing'); this works fine on desktop browsers, on windows phone, scrolls user 180 pixels, stops. have tried replacing function with:
$('html,body').scrolltop(0); it snaps top on desktops, scrolls top on phone. believe need internet explorer mobile try smoothly animate scrolling, , causing issue. if case (or if not, correct me), how can override function animation work?
edit
although not ideal, seem work in limited capacity, have replaced scroll code this:
$('html,body').animate({scrolltop:0}, 150, 'swing', function() { $('html,body').scrolltop(0); }); but know if there option disable smooth scrolling in mobile ie programatically.
on windows phone 8, running same problem. doing following hack, waits until animation "complete" , executes standard window.scrollto ensure scrolled proper location.
scrollhmtlbody: function (scrolltotarget, duration) { $('html, body').animate({ scrolltop: scrolltotarget }, duration); // windows phone doesn't animate properly, // makes sure scrolls appropriate position (eventually) settimeout(function() { window.scrollto(0, scrolltotarget); }, duration + 75); } i not happy result - works, because of 75ms delay has hesitation before "finishes" scroll animation. less of delay, windows phone apparently refuses perform scrollto action (maybe thinks "scrolling"?)
i may end resorting if/else clause device detection, right trying find better solution rather going down road.
Comments
Post a Comment