fix: 修复真机上disabledaction无效问题

This commit is contained in:
0JARVIS0 2019-12-02 09:23:20 +08:00
parent 1836c3458a
commit 6baedf5ba1
2 changed files with 15 additions and 6 deletions

View File

@ -15,6 +15,7 @@ Component({
paintCount: 0,
currentPalette: {},
movingCache: {},
isDisabled: false,
needClear: false,
/**
* 组件的属性列表
@ -75,10 +76,7 @@ Component({
disableAction: {
type: Boolean,
observer: function (isDisabled) {
let style = isDisabled ? 'visibility: hidden' : ''
this.setData({
frontStyle: style
})
this.isDisabled = isDisabled
}
},
clearActionBox: {
@ -101,7 +99,6 @@ Component({
picURL: '',
showCanvas: true,
painterStyle: '',
frontStyle: '',
},
methods: {
@ -473,6 +470,9 @@ Component({
isScale: false,
startTimeStamp: 0,
onTouchStart(event) {
if (this.isDisabled) {
return
}
const {
x,
y
@ -496,6 +496,9 @@ Component({
},
onTouchEnd(e) {
if (this.isDisabled) {
return
}
const current = new Date().getTime()
if ((current - this.startTimeStamp) <= 500 && !this.hasMove) {
!this.isScale && this.onClick(e)
@ -508,11 +511,17 @@ Component({
},
onTouchCancel(e) {
if (this.isDisabled) {
return
}
this.onTouchEnd(e)
},
hasMove: false,
onTouchMove(event) {
if (this.isDisabled) {
return
}
this.hasMove = true
if (!this.touchedView || (this.touchedView && !this.touchedView.id)) {
return

View File

@ -5,7 +5,7 @@
<canvas canvas-id="top" style="{{painterStyle}};position: absolute;" />
<canvas
canvas-id="front"
style="{{painterStyle}};position: absolute;{{frontStyle}};"
style="{{painterStyle}};position: absolute;"
bindtouchstart="onTouchStart"
bindtouchmove="onTouchMove"
bindtouchend="onTouchEnd"