繁体   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
        );
    }
});

到目前为止,该代码在台式机浏览器和iOS上都运行良好。 但是,当我在Android设备上运行此代码时,页面会闪烁,然后移至下一页。 它应触发幻灯片过渡选项,但未显示幻灯片效果。

如何在Android网络应用或移动浏览器上设置幻灯片效果? 我已经尝试过$(id).animate方法,但是没有运气。 我不知道该怎么做才能触发幻灯片效果。

是否有已经尝试过滑动功能的Android开发人员? 有人可以告诉我如何调整$.mobile.changePage的滑动效果吗?

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

只看到淡入淡出过渡? 要查看所有过渡类型,您必须使用支持3D变换的浏览器。 默认情况下,缺少3D支持的设备(例如Android 2.x)对于所有过渡类型都将退回到“淡入淡出”状态。 此行为是可配置的(请参见下文)。

要检查您的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')
}

}

鲁尼所说的是真的。 浏览器说它不支持过渡。 但是...让我们不同意浏览器并继续这样做。 在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;
};

至:

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

然后您就可以使用了。

但是您必须了解浏览器不会无缘无故地说它不支持它。 例如,Android上的浏览器在首次转换时会失败(不是Chrome)。

暂无
暂无

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

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