离子框架中的滑动指令? [英] swipe directive in ionic framework?

查看:85
本文介绍了离子框架中的滑动指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ionic是否有滑动或其他事件的指令?

我找到了这项服务: $ ionicGesture 。我应该用这个制作我自己的指令吗?

Does ionic has directives for swiping or other events?
I found this service: $ionicGesture. Should I make my own directives with this?

或者我应该使用像ngTouch这样的东西吗?

Or should I use something else like ngTouch?

推荐答案

开箱即用没有任何滑动指令,但由于事件已暴露,因此将某些东西放在一起非常简单。

There aren't any swipe directives right out of the box, but since the events are exposed, it's pretty simple to throw something together.

.directive('detectGestures', function($ionicGesture) {
  return {
    restrict :  'A',

    link : function(scope, elem, attrs) {
      var gestureType = attrs.gestureType;

      switch(gestureType) {
        case 'swipe':
          $ionicGesture.on('swipe', scope.reportEvent, elem);
          break;
        case 'swiperight':
          $ionicGesture.on('swiperight', scope.reportEvent, elem);
          break;
        case 'swipeleft':
          $ionicGesture.on('swipeleft', scope.reportEvent, elem);
          break;
        case 'doubletap':
          $ionicGesture.on('doubletap', scope.reportEvent, elem);
          break;
        case 'tap':
          $ionicGesture.on('tap', scope.reportEvent, elem);
          break;
      }

    }
  }
})

查看此演示

这篇关于离子框架中的滑动指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆