3

I try to bring some effects to my tabs navigation on my jquery-mobile page but it looks like that the data-transitions argument does not work combined with a tabs navigation.

My code looks like this:

<div data-role="header" data-theme="a" id="header">
<h1>Mainpage</h1>
</div>

<div data-role="main" class="ui-content">
<div data-role="tabs" id="tabs" >
  <div data-role="navbar" data-iconpos="left">
    <ul>
        <li><a id="lblTab1" href="#location" data-ajax="false" class="ui-btn-active" data-icon="search" data-transition="pop">search</a></li>
        <li><a id="lblTab2" href="#product" data-ajax="false" data-icon="location" data-transition="pop">product</a></li>
    </ul>
  </div>
  <div id="location" class="ui-body-d ui-content" > content </div>
  <div id="product" class="ui-body-d ui-content" > content2  </div>
</div>
</div>
</div>

so how is it possible to bring some effects to the navigation bar?

I use jquery-mobile 1.4.0

4

1 回答 1

3

页面转换不适用于选项卡,因为在隐藏/显示页面时会激活转换类。您可以创建自己的过渡,使用第三方 CSS 过渡或使用 jQM 默认过渡。

首先,您需要监听tabbeforeactivate事件。此事件省略ui包含上一个 ( ui.oldPanel) 和下一个面板 ( ui.newPanel) 的数据的对象。您需要做的就是添加动画ui-newPanel并在动画结束后将其删除,方法是绑定Animation End 一次,仅使用.one().

$("#tabs").on("tabbeforeactivate", function (e, ui) {
  $(ui.newPanel)
      .addClass("animation")
      .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
    $(this).removeClass("animation");
  });
});

演示- Daneden的自定义动画

演示- jQM 默认转换

于 2014-02-24T02:08:15.780 回答