Clean up debug code for image pinch zoom
This commit is contained in:
parent
49fa9c47e9
commit
5829cd98af
|
@ -103,7 +103,6 @@ const MediaModal = {
|
||||||
this.$refs.pinchZoom.setTransform({ scale: 1, x: offsets[0], y: 0 })
|
this.$refs.pinchZoom.setTransform({ scale: 1, x: offsets[0], y: 0 })
|
||||||
},
|
},
|
||||||
handleSwipeEnd (sign) {
|
handleSwipeEnd (sign) {
|
||||||
console.log('handleSwipeEnd:', sign)
|
|
||||||
this.$refs.pinchZoom.setTransform({ scale: 1, x: 0, y: 0 })
|
this.$refs.pinchZoom.setTransform({ scale: 1, x: 0, y: 0 })
|
||||||
if (sign > 0) {
|
if (sign > 0) {
|
||||||
this.goNext()
|
this.goNext()
|
||||||
|
|
|
@ -25,9 +25,6 @@ const project = (v1, v2) => {
|
||||||
return [scalar * v2[0], scalar * v2[1]]
|
return [scalar * v2[0], scalar * v2[1]]
|
||||||
}
|
}
|
||||||
|
|
||||||
// const debug = console.log
|
|
||||||
const debug = () => {}
|
|
||||||
|
|
||||||
// direction: either use the constants above or an arbitrary 2d vector.
|
// direction: either use the constants above or an arbitrary 2d vector.
|
||||||
// threshold: how many Px to move from touch origin before checking if the
|
// threshold: how many Px to move from touch origin before checking if the
|
||||||
// callback should be called.
|
// callback should be called.
|
||||||
|
@ -86,7 +83,7 @@ class SwipeAndClickGesture {
|
||||||
swipelessClickCallback,
|
swipelessClickCallback,
|
||||||
threshold = 30, perpendicularTolerance = 1.0
|
threshold = 30, perpendicularTolerance = 1.0
|
||||||
}) {
|
}) {
|
||||||
const nop = () => { debug('Warning: Not implemented') }
|
const nop = () => {}
|
||||||
this.direction = direction
|
this.direction = direction
|
||||||
this.swipePreviewCallback = swipePreviewCallback || nop
|
this.swipePreviewCallback = swipePreviewCallback || nop
|
||||||
this.swipeEndCallback = swipeEndCallback || nop
|
this.swipeEndCallback = swipeEndCallback || nop
|
||||||
|
@ -106,8 +103,6 @@ class SwipeAndClickGesture {
|
||||||
}
|
}
|
||||||
|
|
||||||
start (event) {
|
start (event) {
|
||||||
debug('start() called', event)
|
|
||||||
|
|
||||||
// Only handle left click
|
// Only handle left click
|
||||||
if (event.button !== BUTTON_LEFT) {
|
if (event.button !== BUTTON_LEFT) {
|
||||||
return
|
return
|
||||||
|
@ -115,7 +110,6 @@ class SwipeAndClickGesture {
|
||||||
|
|
||||||
this._startPos = pointerEventCoord(event)
|
this._startPos = pointerEventCoord(event)
|
||||||
this._pointerId = event.pointerId
|
this._pointerId = event.pointerId
|
||||||
debug('start pos:', this._startPos)
|
|
||||||
this._swiping = true
|
this._swiping = true
|
||||||
this._swiped = false
|
this._swiped = false
|
||||||
}
|
}
|
||||||
|
@ -132,7 +126,6 @@ class SwipeAndClickGesture {
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel (event) {
|
cancel (event) {
|
||||||
debug('cancel called')
|
|
||||||
if (!this._swiping || this._pointerId !== event.pointerId) {
|
if (!this._swiping || this._pointerId !== event.pointerId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -142,29 +135,20 @@ class SwipeAndClickGesture {
|
||||||
|
|
||||||
end (event) {
|
end (event) {
|
||||||
if (!this._swiping) {
|
if (!this._swiping) {
|
||||||
debug('not swiping')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._pointerId !== event.pointerId) {
|
if (this._pointerId !== event.pointerId) {
|
||||||
debug('pointer id does not match')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this._swiping = false
|
this._swiping = false
|
||||||
|
|
||||||
debug('end: is swipe event')
|
|
||||||
|
|
||||||
debug('button = ', event.button)
|
|
||||||
|
|
||||||
// movement too small
|
// movement too small
|
||||||
const coord = pointerEventCoord(event)
|
const coord = pointerEventCoord(event)
|
||||||
const delta = deltaCoord(this._startPos, coord)
|
const delta = deltaCoord(this._startPos, coord)
|
||||||
|
|
||||||
const sign = (() => {
|
const sign = (() => {
|
||||||
debug(
|
|
||||||
'threshold = ', this.threshold(),
|
|
||||||
'vector len =', vectorLength(delta))
|
|
||||||
if (vectorLength(delta) < this.threshold()) {
|
if (vectorLength(delta) < this.threshold()) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue