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

View File

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