Skip to content

Commit

Permalink
Merge pull request #67 from AnastasiaBuniakEPAM/JS-359
Browse files Browse the repository at this point in the history
JS-359: Magnifier on preview swipe/drag
  • Loading branch information
uharbachou1 committed Dec 10, 2015
2 parents 5ee9da5 + d322132 commit fe035ba
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/web/magnifier/magnify.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ define([
zoomOutDisabled = 'fotorama__zoom-out--disabled',
videoContainerClass = 'fotorama-video-container',
hideMagnifier,
behaveOnHover,
dragFlag,
endX,
allowZoomOut = false,
Expand Down Expand Up @@ -758,24 +757,22 @@ define([
/**
* Hides magnifier on drag and while arrow click.
*/
behaveOnHover = function (e, initPos) {
function behaveOnDrag (e, initPos) {
var pos = [e.pageX, e.pageY],
isArrow = $(e.target).data('gallery-role') === 'arrow',
isClick = initPos[0] === pos[0] && initPos[1] === pos[1],
isImg = $(e.target).parent().data('active');

if ((isImg && !isClick) || isArrow) {
if (isArrow || (isImg && !isClick)) {
hideMagnifier();
}
};
}

if (config.magnifierOpts.eventType === 'click') {
config.options.swipe = false;
} else if (config.magnifierOpts.eventType === 'hover') {
if (config.magnifierOpts.enabled) {
$(element).on('pointerdown mousedown MSPointerDown', function (e) {
var pos = [e.pageX, e.pageY];
$(element).on('mousemove pointermove MSPointerMove', function (ev) {
navigator.msPointerEnabled ? hideMagnifier() : behaveOnHover(ev, pos);
navigator.msPointerEnabled ? hideMagnifier() : behaveOnDrag(ev, pos);
});
$(document).on('mouseup pointerup MSPointerUp', function () {
$(element).off('mousemove pointermove MSPointerMove');
Expand Down

0 comments on commit fe035ba

Please sign in to comment.