【问题标题】:Call JQuery Mobile transition with Javascript使用 Javascript 调用 JQuery Mobile 转换
【发布时间】:2013-04-10 14:37:27
【问题描述】:

我正在使用 Hammer.js 添加滑动手势以滑动浏览我的网站页面。

现在我想使用 JQuery Mobile 添加一个转换,但转换是在 HTML 中调用的。是否有可能调用动画:

data-transition="slide"

通过 Javascript。

<script type="text/javascript">
var hammertime = Hammer('html', {swipe_max_touches: 2, prevent_mouseevents: true
}).on("swiperight", function(event) {
document.location = "http://example.com";
});

【问题讨论】:

  • 我知道 JQuery Mobile 的新功能“滑动导航”,但我想使用 Hammer.js

标签: javascript jquery mobile transition swipe


【解决方案1】:

$.mobile.changePage() 现已弃用。 http://api.jquerymobile.com/jQuery.mobile.changePage/。正确的方法是使用:

  1. $.mobile.navigate("#bar", {transition: "slide", info: "info about the #bar hash"});
  2. $.mobile.pageContainer.pagecontainer("change", "target", {transition: "flow", changeHash: false, reload: true})

只是想我会根据我从其他线程中学到的知识来回答这个问题。 我没有足够的声誉来放置其余的链接。只需在 Google 上搜索代码即可找到它们各自的 StackOverflow 线程。

【讨论】:

  • 有点晚了,等我需要的时候再看看
【解决方案2】:

你可以使用

$.mobile.changePage( url, { transition: "slideup" });

jQueryMobile documentation

要缩短加载时间,您可以使用 prefetching 例如

<a href="url" data-prefetch="true" data-rel="dialog" class="ui-link">
  This link will prefetch the page
</a>

【讨论】:

  • 您可以使用预取来尝试加快加载时间
猜你喜欢
  • 2012-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多