Javascript 更改 jQuery Mobile 过渡方向

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9053924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 08:31:10  来源:igfitidea点击:

Changing jQuery Mobile transition directions

javascriptjquerymobilejquery-mobile

提问by Sallar

I'm working on a web app, which I decided to use jQuery Mobile for it. The problem is my website is in Persian language which is a Right-to-Left language. I've created an rtl.css stylesheet which reverses everything, but I need to also reverse default slide transitions, meaning that it should slide from left to right and when adding data-reverse or back button it should slide right to left.

我正在开发一个网络应用程序,我决定为此使用 jQuery Mobile。问题是我的网站是波斯语,这是一种从右到左的语言。我创建了一个 rtl.css 样式表,它可以反转所有内容,但我还需要反转默认的幻灯片过渡,这意味着它应该从左向右滑动,并且在添加数据反转或后退按钮时它应该从右向左滑动。

Can you please help me with this?
Thanks.

你能帮我解决这个问题吗?
谢谢。

回答by Zakaria

You can check the documentation here.

您可以在此处查看文档

In your case, you should put this :

在你的情况下,你应该把这个:

$.mobile.changePage( "nextPage.html", {
    transition: "slide",
    reverse: true
});

There is another method: You can use the data-directionattribute in the link.

还有另一种方法:您可以使用data-direction链接中的属性。

Exemple :

例子:

<a href="nextPage.html" data-transition="slide", data-direction: "reverse">Next page</a>

I think that you can set it globally in that way : you can find the following statement in the jQuery Mobile JS :

我认为您可以通过这种方式全局设置它:您可以在 jQuery Mobile JS 中找到以下语句:

a.mobile.changePage.defaults

At that line, you can change reverse:falseto reverse:true.

在该行,您可以更改reverse:falsereverse:true

回答by leojh

For markup, this seems to provide for a better slide effect and also more in-line with what jQuery Mobile does in their docs.

对于标记,这似乎提供了更好的幻灯片效果,也更符合 jQuery Mobile 在他们的文档中所做的。

<a href="#main" data-transition="slide" data-direction="reverse">

回答by Phill Pafford

I don't think there is a Global option but you could iterate through all the page and add the attribute

我认为没有 Global 选项,但您可以遍历所有页面并添加属性

data-direction="reverse"

jQM Docs:

jQM 文档:

but @Zakaria is also a valid response

但@Zakaria 也是一个有效的回应