小程序手势(小程序手势缩放)

华为云服务器特价优惠火热进行中!

2核2G2兆仅需 38 元;4核4G3兆仅需 79 元。购买时间越长越优惠!更多配置及优惠价格请咨询客服。

合作流程:
1、点击链接注册/关联华为云账号:点击跳转
2、添加客服微信号:cloud7591,确定产品方案、价格方案、服务支持方案等;
3、客服协助购买,并拉微信技术服务群,享受一对一免费技术支持服务;
技术专家在金蝶、华为、腾讯原厂有多年工作经验,并已从事云计算服务8年,可对域名、备案、网站搭建、系统部署、AI人工智能、云资源规划等上云常见问题提供更专业靠谱的服务,对相应产品提供更优惠的报价和方案,欢迎咨询。

本篇文章给大家谈谈小程序手势,以及小程序手势缩放对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

微信号:cloud7591
如需了解更多,欢迎添加客服微信咨询。
复制微信号

本文目录一览:

如何用微信小程序开发手势解锁

整个功能基于canvas实现,首先添加画布组件,并设定样式

!--index.wxml--view class="container"

canvas canvas-id="id-gesture-lock" class="gesture-lock" bindtouchstart="onTouchStart"

bindtouchmove="onTouchMove" bindtouchend="onTouchEnd"/canvas/view.gesture-lock {

margin: 100rpx auto;

width: 300px;

height: 300px;

background-color: #ffffff;

}123456789101112

手势解锁实现代码在gesture_lock.js中(完整源码地址见末尾)。

初始化

constructor(canvasid, context, cb, opt){ this.touchPoints = []; this.checkPoints = []; this.canvasid = canvasid; this.ctx = context; this.width = opt opt.width || 300; //画布长度

this.height = opt opt.height || 300; //画布宽度族毕

this.cycleNum = opt opt.cycleNum || 3; this.radius = 0; //触摸点半径

this.isParamOk = false; this.marge = this.margeCircle = 25; //触摸点及触摸点和画布边界间隔

this.initColor = opt opt.initColor || '#C5C5C3';

this.checkColor = opt opt.checkColor || '陆厅#5AA9EC'; this.errorColor = opt opt.errorColor || '#e19984'; this.touchState = "unTouch"; this.checkParam(); this.lastCheckPoint = null; if (this.isParamOk) { // 计算触摸点的半径长度

this.radius = (this.width - this.marge * 2 - (this.margeCircle * (this.cycleNum - 1))) / (this.cycleNum * 2) this.radius = Math.floor(this.radius); // 计算每个触摸点的圆心位置

this.calCircleParams();

} this.onEnd = cb; //滑动手势结束时的回调函数

}1234567891011121314151617181920212223242526

主要设置一些参数,如canvas的长宽,canvas的context,手势锁的个数(3乘3, 4乘4),手势锁的颜色,手势滑动结束时的回调函数等。并计算出手势锁的半径。

计算每个手早穗隐势锁的圆心位置

calCircleParams() { let n = this.cycleNum; let count = 0; for (let i = 0; i n; i++) { for (let j = 0; j n; j++){

count++; let touchPoint = {

x: this.marge + i * (this.radius * 2 + this.margeCircle) + this.radius,

y: this.marge + j * (this.radius * 2 + this.margeCircle) + this.radius,

index: count,

check: "uncheck",

} this.touchPoints.push(touchPoint)

}

}

}1234567891011121314151617

绘制手势锁

for (let i = 0; i this.touchPoints.length; i++){ this.drawCircle(this.touchPoints[i].x, this.touchPoints[i].y, this.radius, this.initColor)

} this.ctx.draw(true);1234

接下来就是识别用户的滑动行为,判断用户划过了哪些圆圈,进而识别出用户的手势。

在touchstart和touchmove事件中检测触发并更新画布

onTouchStart(e) { // 不识别多点触控

if (e.touches.length 1){ this.touchState = "unTouch"; return;

} this.touchState = "startTouch"; this.checkTouch(e); let point = {x:e.touches[0].x, y:e.touches[0].y}; this.drawCanvas(this.checkColor, point);

}

onTouchMove(e) { if (e.touchState === "unTouch") { return;

} if (e.touches.length 1){ this.touchState = "unTouch"; return;

} this.checkTouch(e); let point = {x:e.touches[0].x, y:e.touches[0].y}; this.drawCanvas(this.checkColor, point);

}123456789101112131415161718192021222324

检测用户是否划过某个圆圈

checkTouch(e) { for (let i = 0; i this.touchPoints.length; i++){ let point = this.touchPoints[i]; if (isPointInCycle(e.touches[0].x, e.touches[0].y, point.x, point.y, this.radius)) { if (point.check === 'uncheck') { this.checkPoints.push(point); this.lastCheckPoint = point;

}

point.check = "check"

return;

}

}

}12345678910111213

更新画布

drawCanvas(color, point) { //每次更新之前先清空画布

this.ctx.clearRect(0, 0, this.width, this.height); //使用不同颜色和形式绘制已触发和未触发的锁

for (let i = 0; i this.touchPoints.length; i++){ let point = this.touchPoints[i]; if (point.check === "check") { this.drawCircle(point.x, point.y, this.radius, color); this.drawCircleCentre(point.x, point.y, color);

} else { this.drawCircle(this.touchPoints[i].x, this.touchPoints[i].y, this.radius, this.initColor)

}

} //绘制已识别锁之间的线段

if (this.checkPoints.length 1) { let lastPoint = this.checkPoints[0]; for (let i = 1; i this.checkPoints.length; i++) { this.drawLine(lastPoint, this.checkPoints[i], color);

lastPoint = this.checkPoints[i];

}

} //绘制最后一个识别锁和当前触摸点之间的线段

if (this.lastCheckPoint point) { this.drawLine(this.lastCheckPoint, point, color);

} this.ctx.draw(true);

}12345678910111213141516171819202122232425262728

当用户滑动结束时调用回调函数并传递识别出的手势

onTouchEnd(e) { typeof this.onEnd === 'function' this.onEnd(this.checkPoints, false);

}

onTouchCancel(e) { typeof this.onEnd === 'function' this.onEnd(this.checkPoints, true);

}1234567

重置和显示手势错误

gestureError() { this.drawCanvas(this.errorColor)

}

reset() { for (let i = 0; i this.touchPoints.length; i++) { this.touchPoints[i].check = 'uncheck';

} this.checkPoints = []; this.lastCheckPoint = null; this.drawCanvas(this.initColor);

}123456789101112

如何调用

在onload方法中创建lock对象并在用户触摸事件中调用相应方法

onLoad: function () {

var s = this; this.lock = new Lock("id-gesture-lock", wx.createCanvasContext("id-gesture-lock"), function(checkPoints, isCancel) {

console.log('over');

s.lock.gestureError();

setTimeout(function() {

s.lock.reset();

}, 1000);

}, {width:300, height:300}) this.lock.drawGestureLock();

console.log('onLoad') var that = this

//调用应用实例的方法获取全局数据

app.getUserInfo(function(userInfo){

//更新数据

that.setData({

userInfo:userInfo

})

that.update()

})

},

onTouchStart: function (e) {

this.lock.onTouchStart(e);

},

onTouchMove: function (e) {

this.lock.onTouchMove(e);

},

onTouchEnd: function (e) {

this.lock.onTouchEnd(e);

}

粤税通小程序可以设置手势密码登录?

不可以。

微信搜索粤税通小程序微信搜索粤税通小程序,点击登录进行刷脸识别登录或微信支付密码登,没有手势密码。

粤税通是一款办税服务软件,粤税通app提供了线上缴税、业务办理、业务自信等功能服务。为用户带来最贴心的便捷体验,粤税通app还能随时查询办税地图信。

怎么解决小程序中video随手势移动问题

你好。

关于微信亮厅小程序把video固定在页面顶端的问题,解决方案如下:

1.video fixed布局会造成:视频移动,黑色底留下

2.flex布局,video固定高度,自适应部分用scroll-view, 代码如下:晌稿

.grid-box{

width: 100%;

height: 100%;

display: flex;

flex-direction: column;

}

.grid-const{width: 750rpx;height: 422rpx;}

.grid-var{flex: 1;}

.content{height: 100%;}

以上代码可以满足需求,但是下拉页面,video还是会跟着移动

3.最终解决宴键孝方案,禁止页面Page滚动:

在json配置文件中添加:“disableScroll”:true

经测试,页面效果和腾讯视频一致。

微信小程序传奇电脑版怎么键盘操作

微唤段信小程序传奇电脑版键盘操作说明:

1. WASD 控制角色的面向及行走;

2. Tab 开启/关闭地图;

3. 空格键跳跃;

4. Ctrl+鼠标左键点李孝击可以攻击怪物;

5. 鼠标右键点击可以使用物品;

6. 1-9键可以使用英雄背包里的物品;

7. Shift+鼠标左键可以普通拾取;

8. Shift+鼠标右键可以快速拾取;

9. F1-F5键可以使用快捷键功能;

10. Enter键用于哪链稿聊天;

小米哪个键向上划是小程序见

小米手机设置向上滑清理应用程序是手势指令,全面屏手机才能设置,部分机型是没有的。在小米mix3手机中,可参考以下步骤向上滑清理应用程序:1、首先在手机的桌面,从最下方往上滑动。

2、这样就可以看到在手机上,已经打开了所有手机应用了,可以选中其中的应用,向左滑动,或者向右滑动。

3、选择设置毕庆渣向右滑动就可手悄以看到,就可以关闭这个应用了。

4、如果想要一次性关闭手机上所有已经打开的差模手机应用的话,就可以点击页面最下方的小叉号。

5、最后就可以看到,手机上的所有已经打开的应用都被关闭了。

小程序手势的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于小程序手势缩放、小程序手势的信息别忘了在本站进行查找喔。

发布于 2023-04-13 18:04:18
收藏
分享
海报
27
目录

    忘记密码?

    图形验证码

    复制成功
    微信号: cloud7591
    如需了解更多,欢迎添加客服微信咨询。
    我知道了