Skip to content

Commit 299dae8

Browse files
committed
refactor: do not ignore close when manually calling the move method
1 parent 6150c5b commit 299dae8

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## next
4+
5+
- Do not close the viewer when dragging the image on the backdrop (#577).
6+
37
## 1.11.1 (Nov 6, 2022)
48

59
- Add missing type definitions for `initialCoverage` option and `zoom` and `zoomTo` methods (#571).

src/js/handlers.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232

3333
export default {
3434
click(event) {
35-
const { options, imageData, ignoreCloseOnceMoved } = this;
35+
const { options, imageData } = this;
3636
let { target } = event;
3737
let action = getData(target, DATA_ACTION);
3838

@@ -63,7 +63,7 @@ export default {
6363
break;
6464

6565
case 'hide':
66-
if (ignoreCloseOnceMoved !== true) {
66+
if (!this.pointerMoved) {
6767
this.hide();
6868
}
6969
break;
@@ -337,6 +337,8 @@ export default {
337337
const { options, pointers } = this;
338338
const { buttons, button } = event;
339339

340+
this.pointerMoved = false;
341+
340342
if (
341343
!this.viewed
342344
|| this.showing
@@ -393,6 +395,7 @@ export default {
393395
}
394396

395397
event.preventDefault();
398+
this.pointerMoved = true;
396399

397400
if (event.changedTouches) {
398401
forEach(event.changedTouches, (touch) => {
@@ -406,9 +409,7 @@ export default {
406409
},
407410

408411
pointerup(event) {
409-
const {
410-
options, action, pointers, ignoreCloseOnceMoved,
411-
} = this;
412+
const { options, action, pointers } = this;
412413
let pointer;
413414

414415
if (event.changedTouches) {
@@ -421,12 +422,6 @@ export default {
421422
delete pointers[event.pointerId || 0];
422423
}
423424

424-
if (ignoreCloseOnceMoved) {
425-
setTimeout(() => {
426-
this.ignoreCloseOnceMoved = false;
427-
});
428-
}
429-
430425
if (!action) {
431426
return;
432427
}

src/js/methods.js

-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ export default {
482482
imageData.left = x;
483483
imageData.top = y;
484484
this.moving = true;
485-
this.ignoreCloseOnceMoved = true;
486485
this.renderImage(() => {
487486
this.moving = false;
488487

src/js/viewer.js

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class Viewer {
8484
this.viewing = false;
8585
this.wheeling = false;
8686
this.zooming = false;
87+
this.pointerMoved = false;
8788
this.id = getUniqueID();
8889
this.init();
8990
}

0 commit comments

Comments
 (0)