安装工具函数
npm install micro-touch micro-transform2d --save
micro-transform2d使用说明
micro-touch使用说明
实现举例
let pullN = 0.2;
let tg = new TouchGesture(divDom.current);
let t2d = new Transform2D(divDom.current);
t2d.setTranslate(50, 0);
tg.on("tapDown", function () {
divDom.current.style.removeProperty("transition");
t2d.setTranslate(50, 0);
});
tg.on("pressMove", function (e) {
let {moveDistance: {x, y, d}} = e;
let [nowX, nowY] = t2d.getTranslate();
if (nowY > 50) {
y *= pullN;
}
t2d.setTranslate(50, nowY + y);
});
tg.on("tapUp", function () {
divDom.current.style.transition = "500ms";
t2d.setTranslate(50, 0);
});
网友评论