vue 多点触控手势_vue手势解决方案

本文介绍了一个使用Vue结合AlloyFinger库实现的多点触控手势解决方案。通过监听`touchStart`, `touchMove`, `touchEnd`等事件,实现了元素的平移、旋转和缩放。同时,利用`multipointStart`和`multipointEnd`处理多点触摸,并对边界进行了检查,防止元素越界。" 119493109,5663143,深入理解C++泛型编程,"['C++编程', '泛型', '模板技术', 'STL库', '编程思想']
摘要由CSDN通过智能技术生成

mounted() {this.getData();this.requireList = document.getElementsByClassName('required');

let swordEle= document.getElementsByClassName('swordPic')[0];

let bwidth, bheight, swidth, sheight;

Transform(swordEle);var initScale = 1;var af = newAlloyFinger(swordEle, {

touchStart:function() {

console.log('touchStart')

},

touchMove:function(evt) {

swordEle.style.translateX+=evt.deltaX;

swordEle.style.translateY+=evt.deltaY;

evt.preventDefault();

},

touchEnd:function() {

console.log('end')

console.log(swordEle.style.transform)

},

touchCancel:function() {

console.log('cancel')

},

multipointStart:function() {

initScale=swordEle.scaleX;

},

multipointEnd:function() {

},

tap:function() {

},

doubleTap:function() {

},

longTap:function() {

},

singleTap:function() {

},

rotate:function(evt) {

swordEle.rotateZ+=evt.angle;

},

pinch:function(evt) {

swordEle.scaleX= swordEle.scaleY = initScale *evt.scale;

},

pressMove:function(evt) {

let widthDiff= bwidth -swidth;

let heightDiff= bheight -sheight;

console.log('diff' + widthDiff + ' ' +heightDiff)

console.log('translateX:' + swordEle.translateX + '' +swordEle.translateY )if (((evt.deltaX>0)&&(swordEle.translateX >= widthDiff))||((evt.deltaY>0)&&(swordEle.translateY >= heightDiff))||((swordEle.translateX<0)&&((evt.deltaX<0)))||((swordEle.translateY<0)&&((evt.deltaY<0)))) {

console.log('越界')

}else{

swordEle.translateX+=evt.deltaX;

swordEle.translateY+=evt.deltaY;

}

console.log('pressmve:' +swordEle.translateX)

console.log('pressmve:' +swordEle.translateY)

},

swipe:function(evt) {//console.log("swipe" + evt.direction);

}

});

document.getElementById('coverPic').onload = function() {

bwidth= this.width;

bheight= this.height;

console.log(bwidth+ ' ' +bheight)if (document.body.scrollHeight - document.body.clientHeight > 20) {

document.body.scrollTop=document.body.scrollHeight;

}

}

document.getElementById('swordEle').onload = function() {

swidth= this.width;

sheight= this.height;

console.log(swidth+ ' ' +sheight)

}

},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值