diff --git a/lib/web/magnifier/magnify.js b/lib/web/magnifier/magnify.js index 7d193fc1cd97..631316030aa2 100644 --- a/lib/web/magnifier/magnify.js +++ b/lib/web/magnifier/magnify.js @@ -274,7 +274,7 @@ define([ function toggleStandartNavigation() { var $selectable = $('a[href], area[href], input, select, textarea, button, iframe, object, embed, *[tabindex], *[contenteditable]') - .not('[tabindex=-1], [disabled], :hidden'), + .not('[tabindex=-1], [disabled], :hidden'), fotorama = $(gallerySelector).data('fotorama'), $focus = $(':focus'), index; @@ -520,6 +520,7 @@ define([ * Method which makes draggable picture. Also work on touch devices. */ function magnifierFullscreen(fotorama) { + tapFlag = 0; var isDragActive = false, startX, startY, @@ -613,6 +614,9 @@ define([ * @param e - event object */ function dblClickHandler(e) { + if ($image.length === 0) { + $image = $(fullscreenImageSelector, $gallery); + } var imgOriginalSize = getImageSize($image[0]), proportions; @@ -632,25 +636,18 @@ define([ } function detectDoubleTap(e) { - var now = new Date().getTime(), + let now = new Date().getTime(), timesince = now - tapFlag; - if (timesince < 400 && timesince > 0) { + if (timesince > 20 && (isTouchEnabled && timesince < 400) || (!isTouchEnabled && timesince < 2000)) { transitionActive = false; - tapFlag = 0; dblClickHandler(e); - } else { - tapFlag = new Date().getTime(); } + tapFlag = now; } if (isTouchEnabled) { - $image.off('tap'); - $image.on('tap', function (e) { - if (e.originalEvent.originalEvent.touches.length === 0) { - detectDoubleTap(e); - } - }); + $image.on('touchend', detectDoubleTap); } else { $image.off('dblclick'); $image.on('dblclick', dblClickHandler);