小程序
小游戏
企业微信
微信支付
扫描小程序码分享
这个手机版本循环获取 wx.createSelectorQuery() 的坐标总是有延迟 调试太慢有什么办法解决吗
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
setTimeout(function() {
wx.createSelectorQuery().select('#view-pointer').boundingClientRect(function(rect) {
if (rect.top <= that.data.h5 + w4) {
wx.createSelectorQuery().select('#view-id1').boundingClientRect(function(rect2) {
if (rect2.left + w4 >= left && rect2.left <= left + w6) {
var score = 20;
that.setData({
hidebg1: true,
left1: rect2.left,
score: that.data.score + score,
})
//音乐
that.myAudiocock.seek(0);
that.myAudiocock.play();
that.animationcapture1.translateY(height - that.data.w5 - that.data.h7).step()
that.animationpointer.height(0).step()
that.animationadd.opacity(1).translateY(-15).step()
animationcapture1: that.animationcapture1.export(),
animationpointer: that.animationpointer.export(),
animationadd: that.animationadd.export(),
isok = false;
that.animationcapture1.translateY(0).step()
that.animationadd.opacity(0).translateY(0).step()
hidebg1: false,
}, 300)
}, 60)
} else {
setTimeout(that.getRect, ot1);
}
}).exec()
} else if (rect.top <= h6 + w4 && rect.top >= h6) {
wx.createSelectorQuery().select('#view-id2').boundingClientRect(function(rect1) {
if (rect1.left + w4 >= left && rect1.left < left + w6) {
that.myAudiobomb.seek(0);
that.myAudiobomb.play();
hidebg2: true,
left2: rect1.left,
score: that.data.score - 10,
errornum: 0,
that.erroranimation();
that.animationreduce.opacity(1).translateY(-15).step()
animationreduce: that.animationreduce.export(),
that.animationreduce.opacity(0).translateY(0).step()
}, 2)
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
你好,请提供出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
setTimeout(function() {
wx.createSelectorQuery().select('#view-pointer').boundingClientRect(function(rect) {
if (rect.top <= that.data.h5 + w4) {
wx.createSelectorQuery().select('#view-id1').boundingClientRect(function(rect2) {
if (rect2.left + w4 >= left && rect2.left <= left + w6) {
var score = 20;
that.setData({
hidebg1: true,
left1: rect2.left,
score: that.data.score + score,
})
//音乐
that.myAudiocock.seek(0);
that.myAudiocock.play();
setTimeout(function() {
that.animationcapture1.translateY(height - that.data.w5 - that.data.h7).step()
that.animationpointer.height(0).step()
that.animationadd.opacity(1).translateY(-15).step()
that.setData({
animationcapture1: that.animationcapture1.export(),
animationpointer: that.animationpointer.export(),
animationadd: that.animationadd.export(),
})
isok = false;
setTimeout(function() {
that.animationcapture1.translateY(0).step()
that.animationadd.opacity(0).translateY(0).step()
that.setData({
hidebg1: false,
animationcapture1: that.animationcapture1.export(),
animationadd: that.animationadd.export(),
})
}, 300)
}, 60)
} else {
setTimeout(that.getRect, ot1);
}
}).exec()
} else if (rect.top <= h6 + w4 && rect.top >= h6) {
wx.createSelectorQuery().select('#view-id2').boundingClientRect(function(rect1) {
if (rect1.left + w4 >= left && rect1.left < left + w6) {
//音乐
that.myAudiobomb.seek(0);
that.myAudiobomb.play();
that.setData({
hidebg2: true,
left2: rect1.left,
score: that.data.score - 10,
errornum: 0,
})
setTimeout(function() {
that.erroranimation();
that.animationpointer.height(0).step()
that.animationreduce.opacity(1).translateY(-15).step()
that.setData({
animationpointer: that.animationpointer.export(),
animationreduce: that.animationreduce.export(),
})
isok = false;
setTimeout(function() {
that.animationreduce.opacity(0).translateY(0).step()
that.setData({
animationreduce: that.animationreduce.export(),
})
}, 300)
}, 60)
} else {
setTimeout(that.getRect, ot1);
}
}).exec()
} else {
setTimeout(that.getRect, ot1);
}
}).exec()
}, 2)
你好,请提供出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。