Skip to content

Commit fe035ba

Browse files
committed
Merge pull request #67 from AnastasiaBuniakEPAM/JS-359
JS-359: Magnifier on preview swipe/drag
2 parents 5ee9da5 + d322132 commit fe035ba

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/web/magnifier/magnify.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ define([
2626
zoomOutDisabled = 'fotorama__zoom-out--disabled',
2727
videoContainerClass = 'fotorama-video-container',
2828
hideMagnifier,
29-
behaveOnHover,
3029
dragFlag,
3130
endX,
3231
allowZoomOut = false,
@@ -758,24 +757,22 @@ define([
758757
/**
759758
* Hides magnifier on drag and while arrow click.
760759
*/
761-
behaveOnHover = function (e, initPos) {
760+
function behaveOnDrag (e, initPos) {
762761
var pos = [e.pageX, e.pageY],
763762
isArrow = $(e.target).data('gallery-role') === 'arrow',
764763
isClick = initPos[0] === pos[0] && initPos[1] === pos[1],
765764
isImg = $(e.target).parent().data('active');
766765

767-
if ((isImg && !isClick) || isArrow) {
766+
if (isArrow || (isImg && !isClick)) {
768767
hideMagnifier();
769768
}
770-
};
769+
}
771770

772-
if (config.magnifierOpts.eventType === 'click') {
773-
config.options.swipe = false;
774-
} else if (config.magnifierOpts.eventType === 'hover') {
771+
if (config.magnifierOpts.enabled) {
775772
$(element).on('pointerdown mousedown MSPointerDown', function (e) {
776773
var pos = [e.pageX, e.pageY];
777774
$(element).on('mousemove pointermove MSPointerMove', function (ev) {
778-
navigator.msPointerEnabled ? hideMagnifier() : behaveOnHover(ev, pos);
775+
navigator.msPointerEnabled ? hideMagnifier() : behaveOnDrag(ev, pos);
779776
});
780777
$(document).on('mouseup pointerup MSPointerUp', function () {
781778
$(element).off('mousemove pointermove MSPointerMove');

0 commit comments

Comments
 (0)