fix mouse wheel scroll
(in the right place this time!) //TODO(rafaelcastrocouto): User preference for shift key and zoom factor git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2284 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
bf0a0c991c
commit
a4c4539117
|
@ -3476,12 +3476,16 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
|||
$(container).mousedown(mouseDown).mousemove(mouseMove).click(handleLinkInCanvas).dblclick(dblClick).mouseup(mouseUp);
|
||||
// $(window).mouseup(mouseUp);
|
||||
|
||||
//TODO(rafaelcastrocouto): User preference for shift key and zoom factor
|
||||
$(container).bind("mousewheel DOMMouseScroll", function(e){
|
||||
if(!e.shiftKey) return;
|
||||
console.log(e.preventDefault)
|
||||
//if(!e.shiftKey) return;
|
||||
e.preventDefault();
|
||||
var evt = e.originalEvent;
|
||||
|
||||
root_sctm = svgcontent.getScreenCTM().inverse();
|
||||
var pt = transformPoint( e.pageX, e.pageY, root_sctm );
|
||||
var pt = transformPoint( evt.pageX, evt.pageY, root_sctm );
|
||||
|
||||
var bbox = {
|
||||
'x': pt.x,
|
||||
'y': pt.y,
|
||||
|
@ -3489,23 +3493,11 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
|||
'height': 0
|
||||
};
|
||||
|
||||
// Respond to mouse wheel in IE/Webkit/Opera.
|
||||
// (It returns up/dn motion in multiples of 120)
|
||||
if(e.wheelDelta) {
|
||||
if (e.wheelDelta >= 120) {
|
||||
bbox.factor = 2;
|
||||
} else if (e.wheelDelta <= -120) {
|
||||
bbox.factor = .5;
|
||||
}
|
||||
} else if(e.detail) {
|
||||
if (e.detail > 0) {
|
||||
bbox.factor = .5;
|
||||
} else if (e.detail < 0) {
|
||||
bbox.factor = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if(!bbox.factor) return;
|
||||
var delta = (evt.wheelDelta) ? evt.wheelDelta : (evt.detail) ? -evt.detail : 0;
|
||||
if(!delta) return;
|
||||
|
||||
bbox.factor = Math.max(3/4, Math.min(4/3, (delta)));
|
||||
|
||||
call("zoomed", bbox);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue