-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MouseWheel zoom, and touch support? #13
Comments
I agree on that, and those features were planned but there just wasnt enough time when the plugin was created. I will to extend it as soon as possible with those options. If you want, want, you could help? :) |
change code of line 302 to 328 before to that.img.offset(~~~) that.img.css('z-index', 1000).on("mousemove touchmove", function(e) { |
@ijpe Could you please expand on how to implement the above code? I dont have any line with that.img.offset(~~~) ? Desperate to get it working - would really appreciate your help. |
My initDrag code initDrag:function(){
var that = this;
that.img.on("mousedown touchstart", function(e) {
e.preventDefault(); // disable selection
var pageX;
var pageY;
var userAgent = window.navigator.userAgent;
if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
pageX = e.originalEvent.touches[0].pageX;
pageY = e.originalEvent.touches[0].pageY;
} else {
pageX = e.pageX;
pageY = e.pageY;
}
var z_idx = that.img.css('z-index'),
drg_h = that.img.outerHeight(),
drg_w = that.img.outerWidth(),
pos_y = that.img.offset().top + drg_h - pageY,
pos_x = that.img.offset().left + drg_w - pageX;
that.img.css('z-index', 1000).on("mousemove touchmove", function(e) {
if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
var imgTop = e.originalEvent.touches[0].pageY + pos_y - drg_h;
var imgLeft = e.originalEvent.touches[0].pageX + pos_x - drg_w;
} else {
var imgTop = e.pageY + pos_y - drg_h;
var imgLeft = e.pageX + pos_x - drg_w;
}
that.img.offset({
top:imgTop,
left:imgLeft
}).on("mouseup", function() {
$(this).removeClass('draggable').css('z-index', z_idx);
});
if(that.options.imgEyecandy){ that.imgEyecandy.offset({ top:imgTop, left:imgLeft }); }
if( parseInt( that.img.css('top')) > 0 ){ that.img.css('top',0); if(that.options.imgEyecandy){ that.imgEyecandy.css('top', 0); } }
var maxTop = -( that.imgH-that.objH); if( parseInt( that.img.css('top')) < maxTop){ that.img.css('top', maxTop); if(that.options.imgEyecandy){ that.imgEyecandy.css('top', maxTop); } }
if( parseInt( that.img.css('left')) > 0 ){ that.img.css('left',0); if(that.options.imgEyecandy){ that.imgEyecandy.css('left', 0); }}
var maxLeft = -( that.imgW-that.objW); if( parseInt( that.img.css('left')) < maxLeft){ that.img.css('left', maxLeft); if(that.options.imgEyecandy){ that.imgEyecandy.css('left', maxLeft); } }
if (that.options.onImgDrag) that.options.onImgDrag.call(that);
});
}).on("mouseup", function() {
that.img.off("mousemove");
}).on("mouseout", function() {
that.img.off("mousemove");
});
}, |
Thanks! |
Thanks so much. 👍 |
An upgrade for Drag and mousewheel support has been done. |
Thank you for the upgrade.
|
Would really like to see mousewheel zoom, and touch support. currently useless on mobile devices, and mousewheel feels much more natural than button clicks for zooming.
The text was updated successfully, but these errors were encountered: