Skip to content
This repository was archived by the owner on Aug 21, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/e-smart-zoom-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,6 @@
* @param {Object} e : touch event
*/
function touchStartHandler(e){
e.preventDefault(); // prevent default browser drag

$(document).unbind('touchmove.smartZoom'); // unbind if we already listen touch events
$(document).unbind('touchend.smartZoom');

Expand Down Expand Up @@ -408,7 +406,7 @@
*/
function touchMoveHandler(e){

e.preventDefault(); // prevent default browser behaviour
preventDefaultOnDrag(e); // prevent default browser behaviour when the target is zoomed

var smartData = targetElement.data('smartZoomData');

Expand Down Expand Up @@ -456,6 +454,22 @@
}
}

/**
* Prevent default browser behaviour on drag into the target only when it is zoomed
*
* @param {Event} e : the original touch event
*/
function preventDefaultOnDrag(e) {
var smartData = targetElement.data('smartZoomData');
var targetRect = getTargetRect(); // the current plugin target size
var originSize = smartData.originalSize; // original plugin target size
var currentScale = (targetRect.width / originSize.width);

if (currentScale !== 1) {
e.preventDefault();
}
}

/**
* manage touch move end or double tap at touch end
* @param {Object} e : touch event
Expand Down