Try To Resize Image By Hammerjs In Ios Not Work
I try to make image resizable on iOS by Hammer.js gesture. This jsfiddle code work OK on desktop, and this is my converted code (run on iOS safari) var startX,startY,startW,start
Solution 1:
After some days, I realize that Hammer JS is not good in compatible with iOS. I use jQuery touch instead
$("document").ready(function() {
var imgArray = $('img');
for (var i = 0; i < imgArray.length; i++) {
var startX,startY,startW,startH;
var canResize = false;
var image = imgArray[i];
image.addEventListener('touchstart', function(e) {
e.preventDefault();
canResize = true;
var touch = e.touches[0];
startX = touch.pageX;
startY = touch.pageY;
startW = $(this).innerWidth();
startH = $(this).innerHeight();
}, false);
image.addEventListener('touchend', function(e) {
e.preventDefault();
canResize = false;
}, false);
image.addEventListener('touchmove', function(e) {
e.preventDefault();
var touch = e.touches[0];
if (canResize == true) {
$(this).innerWidth(startW + touch.pageX-startX);
$(this).innerHeight(startH + touch.pageY-startY);
}
}, false);
}
});
Post a Comment for "Try To Resize Image By Hammerjs In Ios Not Work"