【问题标题】:Specify Animation Transition on Click指定单击时的动画过渡
【发布时间】:2015-06-28 19:01:29
【问题描述】:

我有一个 Ionic 应用程序,我希望能够指定当用户单击 ui-sref 单击时如何发生转换。目前,如果我单击按钮Scientific Facts,则到下一个视图的幻灯片转换从右到左。我希望它能够从左到右。有什么办法可以用 Ionic 做到这一点?

我的主页。

  <view title="'Home'">
    <content has-header="true" padding="true">
      <p>Example of Ionic tabs. Navigate to each tab, and
      navigate to child views of each tab and notice how
      each tab has its own navigation history.</p>
      <p>
        <!-- Link is here -->
        <a class="button icon icon-right ion-chevron-right" href="#/tab/facts">Scientific Facts</a>
      </p>

      <button class="button" ng-click="modal.show()">Open Modal</button>
    </content>
  </view>

事实页面

<view title="'Facts'">
    <content has-header="true" padding="true">
      <p>Banging your head against a wall uses 150 calories an hour.</p>
      <p>Dogs have four toes on their hind feet, and five on their front feet.</p>
      <p>The ant can lift 50 times its own weight, can pull 30 times its own weight and always falls over on its right side when intoxicated.</p>
      <p>A cockroach will live nine days without it's head, before it starves to death.</p>
      <p>Polar bears are left handed.</p>
      <p>
        <a class="button icon ion-home" href="#/tab/home"> Home</a>
        <a class="button icon icon-right ion-chevron-right" href="#/tab/facts2">More Facts</a>
      </p>
    </content>
  </view>

路线部分在这里。

.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider

  .state('tabs', {
    url: "/tab",
    abstract: true,
    templateUrl: "tabs.html"
  })
  .state('tabs.home', {
    url: "/home",
    views: {
      'home-tab': {
        templateUrl: "home.html",
        controller: 'HomeTabCtrl'
      }
    }
  })
  .state('tabs.facts', {
    url: "/facts",
    views: {
      'home-tab': {
        templateUrl: "facts.html"
      }
    }
  })
})

我有一个代码笔示例here

【问题讨论】:

  • 请解释为什么我被否决了。不要简单地投反对票。这对我一点帮助都没有。
  • 将 nav-direction="..." 添加到您的链接。它接受:前进、后退、退出、进入、交换。 ionicframework.com/docs/api/directive/navDirection
  • 张贴作为答案,我会给你信用。

标签: javascript angularjs animation angular-ui-router ionic


【解决方案1】:

navDirection 指令允许您设置特定链接的导航方向。用法:

<a class="button icon icon-left ion-chevron-left" href="#/tab/facts" nav-direction="back">Scientific Facts</a>

确保您使用的是 Ionic 1.0+ 版。

Plunkr

【讨论】:

    猜你喜欢
    • 2021-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-23
    • 2019-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多