简体   繁体   English

jQuery Mobile:changepage幻灯片过渡在桌面上可以正常运行,但在Android设备上不能正常运行

[英]jQuery Mobile: changepage slide transition working fine on a desktop but not on Android devices

$('div.ui-page').live("swipeleft", function () {
    var nextpage = $(this).next('div[data-role="page"]');
    if (nextpage.length > 0) {
        $.mobile.changePage(
            nextpage,
            {transition: "slide"},
            true,
            true
        );
    }else{
        $.mobile.changePage(
            "#page3",
            {   transition: "slide", 
                reverse:true
            }, 
            true, 
            true
        );
    }
});

The code is working great on a desktop browser, and iOS so far. 到目前为止,该代码在台式机浏览器和iOS上都运行良好。 But when I run this code on an Android device, the page blinks then moves to the next page. 但是,当我在Android设备上运行此代码时,页面会闪烁,然后移至下一页。 It should fire the slide transition option but no slide effect was shown. 它应触发幻灯片过渡选项,但未显示幻灯片效果。

How should I set the slide effect on an Android web app or mobile browser? 如何在Android网络应用或移动浏览器上设置幻灯片效果? I already tried the $(id).animate method but no luck. 我已经尝试过$(id).animate方法,但是没有运气。 I don't know what I should do to trigger the slide effect. 我不知道该怎么做才能触发幻灯片效果。

Is there any android developer who already tried the swipe function? 是否有已经尝试过滑动功能的Android开发人员? Can anybody tell me what I should do to adjust the slide effect of $.mobile.changePage ? 有人可以告诉我如何调整$.mobile.changePage的滑动效果吗?

http://jquerymobile.com/test/docs/pages/page-transitions.html http://jquerymobile.com/test/docs/pages/page-transitions.html

Only seeing fade transitions? 只看到淡入淡出过渡? To view all transition types, you must be on a browser that supports 3D transforms. 要查看所有过渡类型,您必须使用支持3D变换的浏览器。 By default, devices that lack 3D support (such as Android 2.x) will fallback to "fade" for all transition types. 默认情况下,缺少3D支持的设备(例如Android 2.x)对于所有过渡类型都将退回到“淡入淡出”状态。 This behavior is configurable (see below). 此行为是可配置的(请参见下文)。

To check whether your android support it, add that snippet into your javascript 要检查您的Android是否支持该代码段,请将该代码段添加到您的javascript中

window.onload = function () {
var b = document.body.style;
if(b.MozTransition=='' || b.WebkitTransition=='' || b.OTransition=='' || b.transition=='') {
    alert('supported');
} else {
    alert('NOT supported')
}

} }

What roine said is true. 鲁尼所说的是真的。 The browser says it does not support the transition. 浏览器说它不支持过渡。 However... let's not agree with the browser and do it anyway. 但是...让我们不同意浏览器并继续这样做。 In jQuery mobile change: 在jQuery mobile更改中:

// If transition is defined, check if css 3D transforms are supported, and if not, if a fallback is specified
$.mobile._maybeDegradeTransition = function( transition ) {
        if ( transition && !$.support.cssTransform3d && $.mobile.transitionFallbacks[ transition ] ) {
            transition = $.mobile.transitionFallbacks[ transition ];
        }

        return transition;
};

to: 至:

$.mobile._maybeDegradeTransition = function( transition ) {
    return transition;
};

And there you go it works. 然后您就可以使用了。

But you have to understand the browser does not say it doesn't support it for no reason. 但是您必须了解浏览器不会无缘无故地说它不支持它。 For example the browser on Android will fail on first transition (not Chrome). 例如,Android上的浏览器在首次转换时会失败(不是Chrome)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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