sel: do not forgive movement for taps (fix #516)
Signed-off-by: Varun Patil <varunpatil@ucla.edu>pull/563/head
parent
ffd23230ad
commit
24615ddd0d
|
@ -119,12 +119,13 @@ export default defineComponent({
|
||||||
defaultActions: null as ISelectionAction[],
|
defaultActions: null as ISelectionAction[],
|
||||||
|
|
||||||
touchAnchor: null as IPhoto,
|
touchAnchor: null as IPhoto,
|
||||||
|
prevTouch: null as Touch,
|
||||||
touchTimer: 0,
|
touchTimer: 0,
|
||||||
|
touchMoved: false,
|
||||||
touchPrevSel: null as Selection,
|
touchPrevSel: null as Selection,
|
||||||
prevOver: null as IPhoto,
|
prevOver: null as IPhoto,
|
||||||
touchScrollInterval: 0,
|
touchScrollInterval: 0,
|
||||||
touchScrollDelta: 0,
|
touchScrollDelta: 0,
|
||||||
prevTouch: null as Touch,
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -323,6 +324,7 @@ export default defineComponent({
|
||||||
this.prevOver = photo;
|
this.prevOver = photo;
|
||||||
this.prevTouch = event.touches[0];
|
this.prevTouch = event.touches[0];
|
||||||
this.touchPrevSel = new Map(this.selection);
|
this.touchPrevSel = new Map(this.selection);
|
||||||
|
this.touchMoved = false;
|
||||||
this.touchTimer = window.setTimeout(() => {
|
this.touchTimer = window.setTimeout(() => {
|
||||||
if (this.touchAnchor === photo) {
|
if (this.touchAnchor === photo) {
|
||||||
this.selectPhoto(photo, true);
|
this.selectPhoto(photo, true);
|
||||||
|
@ -336,14 +338,19 @@ export default defineComponent({
|
||||||
if (photo.flag & this.c.FLAG_PLACEHOLDER) return;
|
if (photo.flag & this.c.FLAG_PLACEHOLDER) return;
|
||||||
delete this.rows[rowIdx].virtualSticky;
|
delete this.rows[rowIdx].virtualSticky;
|
||||||
|
|
||||||
if (this.touchTimer) this.clickPhoto(photo, {} as any, rowIdx);
|
if (this.touchTimer && !this.touchMoved) {
|
||||||
|
// Register a single tap, only if the touch hadn't moved at all
|
||||||
|
this.clickPhoto(photo, {} as any, rowIdx);
|
||||||
|
}
|
||||||
|
|
||||||
this.resetTouchParams();
|
this.resetTouchParams();
|
||||||
},
|
},
|
||||||
|
|
||||||
resetTouchParams() {
|
resetTouchParams() {
|
||||||
|
this.touchAnchor = null;
|
||||||
window.clearTimeout(this.touchTimer);
|
window.clearTimeout(this.touchTimer);
|
||||||
this.touchTimer = 0;
|
this.touchTimer = 0;
|
||||||
this.touchAnchor = null;
|
this.touchMoved = false;
|
||||||
this.prevOver = undefined;
|
this.prevOver = undefined;
|
||||||
|
|
||||||
window.cancelAnimationFrame(this.touchScrollInterval);
|
window.cancelAnimationFrame(this.touchScrollInterval);
|
||||||
|
@ -363,6 +370,13 @@ export default defineComponent({
|
||||||
const touch: Touch = event.touches[0];
|
const touch: Touch = event.touches[0];
|
||||||
|
|
||||||
if (this.touchTimer) {
|
if (this.touchTimer) {
|
||||||
|
// Regardless of whether we continue to run the timer,
|
||||||
|
// we still need to mark that the touch had moved.
|
||||||
|
// This is so that we can disregard the event if only
|
||||||
|
// registering a tap event (not a long press).
|
||||||
|
// https://github.com/pulsejet/memories/issues/516
|
||||||
|
this.touchMoved = true;
|
||||||
|
|
||||||
// To be more forgiving, check if touch is still
|
// To be more forgiving, check if touch is still
|
||||||
// within 30px of anchor touch (prevTouch)
|
// within 30px of anchor touch (prevTouch)
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in New Issue