Skip to content

Commit 9914545

Browse files
committed
ACP2E-3198: [cloud] Two-finger zoom and move issue on the real mobile device
1 parent f13f84a commit 9914545

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

lib/web/magnifier/magnify.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ define([
234234
top,
235235
left,
236236
right,
237-
bottom,
238237
ratio;
239238

240239
if ($(gallerySelector).data('fotorama').fullScreen) {
@@ -255,11 +254,9 @@ define([
255254
getLeftValue(left, widthStep, dimensions.width, containerWidth) : 0;
256255

257256
right = dragFlag && left < (containerWidth - dimensions.width) / 2 ? 0 : left;
258-
bottom = dragFlag ? 0 : top;
259257

260258
settings = $.extend(dimensions, {
261259
top: top,
262-
bottom: bottom,
263260
left: left,
264261
right: right
265262
});
@@ -370,7 +367,7 @@ define([
370367
return false;
371368
}
372369

373-
function zoomOut(e, xStep, yStep, fitIntoParentFlag = false) {
370+
function zoomOut(e, xStep, yStep) {
374371
var $image,
375372
widthResult,
376373
heightResult,
@@ -381,7 +378,8 @@ define([
381378
imageHeight,
382379
zoomWidthStep,
383380
zoomHeightStep,
384-
ratio;
381+
ratio,
382+
fitIntoParent;
385383

386384
if (allowZoomOut && (!transitionEnabled || !transitionActive) && (isTouchEnabled ||
387385
!$(zoomOutButtonSelector).hasClass(zoomOutDisabled))) {
@@ -407,7 +405,7 @@ define([
407405
zoomWidthStep = xStep || imageWidth - widthResult;
408406
}
409407

410-
let fitIntoParent = function () {
408+
fitIntoParent = function () {
411409
if (ratio > parentWidth / parentHeight) {
412410
widthResult = parentWidth;
413411
zoomWidthStep = imageWidth - widthResult;
@@ -445,10 +443,7 @@ define([
445443
checkFullscreenImagePosition($image, dimensions, zoomWidthStep, zoomHeightStep);
446444
} else {
447445
toggleStandartNavigation();
448-
if (fitIntoParentFlag) {
449-
allowZoomOut = dragFlag = false;
450-
fitIntoParent();
451-
}
446+
fitIntoParent();
452447
}
453448
} else if (heightResult > parentHeight) {
454449
dimensions = {
@@ -463,11 +458,9 @@ define([
463458
};
464459
checkFullscreenImagePosition($image, dimensions, zoomWidthStep, zoomHeightStep);
465460
} else {
461+
allowZoomOut = dragFlag = false;
466462
toggleStandartNavigation();
467-
if (fitIntoParentFlag) {
468-
allowZoomOut = dragFlag = false;
469-
fitIntoParent();
470-
}
463+
fitIntoParent();
471464
}
472465
}
473466

@@ -535,7 +528,8 @@ define([
535528
$imageContainer = $('[data-gallery-role="stage-shaft"] [data-active="true"]'),
536529
gallery = $gallery.data('fotorama'),
537530
evCache = [],
538-
prevDiff = -1;
531+
prevDiff = -1,
532+
preventAction = false;
539533

540534
swipeSlide = _.throttle(function (direction) {
541535
$(gallerySelector).data('fotorama').show(direction);
@@ -631,10 +625,18 @@ define([
631625

632626
if (prevDiff > 0) {
633627
if (curDiff - prevDiff > 0.2 && allowZoomIn) {
628+
preventAction = true;
634629
zoomIn(ev, curDiff, curDiff);
630+
setTimeout(() => {
631+
preventAction = false;
632+
}, 500);
635633
}
636634
if (curDiff - prevDiff < -0.2 && allowZoomOut) {
635+
preventAction = true;
637636
zoomOut(ev, curDiff, curDiff);
637+
setTimeout(() => {
638+
preventAction = false;
639+
}, 500);
638640
}
639641
}
640642

@@ -678,12 +680,7 @@ define([
678680
if (allowZoomIn) {
679681
zoomIn(e, imgOriginalSize.rw - $image.width(), imgOriginalSize.rh - $image.height());
680682
} else if (allowZoomOut) {
681-
zoomOut(
682-
e,
683-
imgOriginalSize.rw * proportions,
684-
imgOriginalSize.rh - $imageContainer.height(),
685-
true
686-
);
683+
zoomOut(e, imgOriginalSize.rw * proportions, imgOriginalSize.rh - $imageContainer.height());
687684
}
688685
}
689686

@@ -695,11 +692,15 @@ define([
695692
const curTime = new Date().getTime();
696693
const tapLen = curTime - lastTap;
697694

698-
if (tapLen < 500 && tapLen > 50) {
695+
if (tapLen < 300 && tapLen > 50 && !preventAction) {
699696
event.preventDefault();
700697

701698
transitionActive = false;
699+
preventAction = true;
702700
dblClickHandler(event);
701+
setTimeout(() => {
702+
preventAction = false;
703+
}, 500);
703704
prevDiff = -1;
704705
} else {
705706
timeout = setTimeout(() => {

0 commit comments

Comments
 (0)