简体   繁体   English

单击时指定动画过渡

[英]Specify Animation Transition on Click

I have an Ionic app and I would love to be able to specify how a transition occurs when a user clicks on a ui-sref click.我有一个 Ionic 应用程序,我希望能够指定当用户单击ui-sref单击时如何发生转换。 Currently if I click on the button Scientific Facts , the slide transition to the next view goes from right to left.目前,如果我点击按钮Scientific Facts ,幻灯片切换到下一个视图从右到左。 I would love for it to be able to go from the left to right.我希望它能够从左到右。 Is there any way I can do this with Ionic?有什么办法可以用 Ionic 做到这一点吗?

My home page.我的主页。

  <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>

The Facts page事实页面

<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>

The routes section is here.路线部分在这里。

.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"
      }
    }
  })
})

I have a codepen example here .这里有一个 codepen 示例。

The navDirection directive allows you to set the direction of the navigation for a specific link. navDirection指令允许您设置特定链接的导航方向。 Usage:用法:

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

Make sure you're using Ionic version 1.0+.确保您使用的是 Ionic 1.0+ 版。

Plunkr普朗克

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

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