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-75d572ba1ddd
master
Rafael Couto 2013-01-16 11:42:18 +00:00
parent bf0a0c991c
commit a4c4539117
1 changed files with 11 additions and 19 deletions

View File

@ -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);
});