AlloyFinger 介绍
alloyfinger是
腾讯Web前端团队推出的轻量级的多点触控手势库,由于其轻量、基于原生js等特性被广泛使用。
其核心 代码 只有300多行,完成了14个手势,其手势并不是浏览器原生的事件,而是通过监听touchstart、touchmove、touchend、touchcancel四个原生浏览器事件hack出来的手势,故其 用法 与原生可能有些不同。比如阻止 默 认事件、阻止冒泡,不能像原生事件那样用。
官方 代码 除了alloyfinger的核心库外还有react、vue的实现。
AlloyFinger安装
npm install alloyfinger
AlloyFinger使用
var af = new AlloyFinger(element,{
touchStart: function () { },
touchMove: function () { },
touchEnd: function () { },
touchCancel: function () { },
multipointStart: function () { },
multipointEnd: function () { },
tap: function () { },
doubleTap: function () { },
longTap: function () { },
singleTap: function () { },
rotate: function (evt) {
console.log(evt.angle);
},
pinch: function (evt) {
console.log(evt.zoom);
},
pressMove: function (evt) {
console.log(evt.deltaX);
console.log(evt.deltaY);
},
swipe: function (evt) {
console.log("swipe" + evt.direction);
}
});
/**
* this method can also add or remove the event handler
*/
var onTap = function() {};
af.on('tap',onTap);
af.on('touchStart',function() {});
af.off('tap',onTap);
/**
* this method can destroy the instance
*/
af = af.destroy();
网站地址 : http://alloyteam.github.io/AlloyFinger/
GitHub: https://github.com/AlloyTeam/AlloyFinger
网站描述: 一款非常轻量的开源手势库
AlloyFinger官方网站
官方网站: http://alloyteam.github.io/AlloyFinger/
如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。