Skip to content

Commit cbde4c0

Browse files
JS-493: Double click doesn't work on mobile
1 parent a463b44 commit cbde4c0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/web/magnifier/magnify.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ define([
581581
var imgOriginalSize = getImageSize($image[0].src),
582582
proportions;
583583

584+
if (imgOriginalSize.rh < $image.parent().height() && imgOriginalSize.rw < $image.parent().width()) {
585+
return;
586+
}
587+
584588
proportions = imgOriginalSize.rw / imgOriginalSize.rh;
585589

586590
if (allowZoomIn) {
@@ -594,15 +598,17 @@ define([
594598
}
595599
}
596600

597-
function detectDoubleTap (e) {
601+
function detectDoubleTap(e) {
598602
var now = new Date().getTime(),
599603
timesince = now - tapFlag;
600604

601-
if (timesince < 500 && timesince > 0) {
605+
if (timesince < 400 && timesince > 0) {
602606
transitionActive = false;
607+
tapFlag = 0;
603608
dblClickHandler(e);
609+
} else {
610+
tapFlag = new Date().getTime();
604611
}
605-
tapFlag = new Date().getTime();
606612
}
607613

608614
$image.unbind('dblclick');
@@ -775,9 +781,9 @@ define([
775781
}
776782
});
777783

778-
isTouchEnabled && $image.off('touchend');
779-
isTouchEnabled && $image.on('touchend', function (e) {
780-
if (e.originalEvent.touches.length === 0) {
784+
isTouchEnabled && $image.off('tap');
785+
isTouchEnabled && $image.on('tap', function (e) {
786+
if (e.originalEvent.originalEvent.touches.length === 0) {
781787
detectDoubleTap(e);
782788
}
783789
});

0 commit comments

Comments
 (0)