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/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。