-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ng-touch #8
Comments
自定义的手势插件
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
引入文件
anguar的单页面页面引入两个脚本,一个angular的框架,一个是触摸的库
<script type="text/javascript" src="dist/js/angular.js"></script>
<script type="text/javascript" src="dist/js/angular-touch.js"></script>
记得在这里引入ngTouch模块
var app = angular.module('wsscat', ['ngRoute','ngTouch']);
编写路由
还要在controller里面把注入$swipe服务,如果我们打印$swipe服务会发现里面只暴露了一个方法bind
touchCtrl控制器
执行$swipe服务的bind方法,bind方法可以传入三个参数
function(element, eventHandlers, pointerTypes)
第一个是获取的节点,可以是directive link方法中获取的element,也可以是原生JS选择器获取的节点,然后放进angular.element函数里面,第二参数是需要监听的触摸动作,总共四个start,move,end和cancel,可以在他们对应的函数中获取对应滑动所在的坐标点
touch视图
<div id="trapezoid"></div>
在控制器中可以有两个事件监听左右滑动(上下滑动却没有)
<p ng-swipe-left="left()" ng-swipe-right="right()">尝试左右滑动</p>
The text was updated successfully, but these errors were encountered: