简体   繁体   中英

body scrollLeft with Android 2.x

I can't make this code run with Android 2.x

$('body').animate({scrollLeft:50});

It's working fine with Android 3/4.

Have your ever met this issue? If so, did you find a workaround?

I finally found a solution ; I use Cordova to detect the Android version, as the workaround does not seem to be compatible with Android 3+:

CSS:

body{
    position:relative;
}

jQuery:

var deviceVersion = device.version.charAt(0);

if (deviceVersion == "2"){
    $('body').animate({left:-50}); // ANDROID 2
}else{
    $('body').animate({scrollLeft:-50}); // ANDROID 3+
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM