Made zoom work on Shift+mousewheel (fails in Opera), made zoom out work on Shift+click in zoom mode

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@884 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2009-10-28 18:04:38 +00:00
parent 21820931c1
commit a7b3b7dd25
2 changed files with 36 additions and 3 deletions

View File

@ -126,7 +126,6 @@ function svg_edit_setup() {
var scrTop = bb.y * zoomlevel;
var scrOffY = w_area.height()/2 - (bb.height * zoomlevel)/2;
w_area[0].scrollTop = Math.max(0,scrTop - scrOffY) + Math.max(0,canvas_pos.top);
clickSelect();
}
// updates the toolbar (colors, opacity, etc) based on the selected element
@ -1070,6 +1069,38 @@ function svg_edit_setup() {
setPushButtons();
$('#workarea').bind("mousewheel DOMMouseScroll", function(e){
if(!e.shiftKey) return;
e.preventDefault();
var off = $('#svgcanvas').offset();
var zoom = svgCanvas.getZoom();
var bbox = {
'x': (e.pageX - off.left)/zoom,
'y': (e.pageY - off.top)/zoom,
'width': 0,
'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;
zoomChanged(window, bbox);
});
// switch modifier key in tooltips if mac
// NOTE: This code is not used yet until I can figure out how to successfully bind ctrl/meta
// in Opera and Chrome

View File

@ -2970,11 +2970,13 @@ function BatchCommand(text) {
if (rubberBox != null) {
rubberBox.setAttribute("display", "none");
}
var factor = evt.shiftKey?.5:2;
call("zoomed", {
'x': Math.min(start_x,x),
'y': Math.min(start_y,y),
'width': Math.abs(x-start_x),
'height': Math.abs(y-start_y)
'height': Math.abs(y-start_y),
'factor': factor
});
return;
case "fhpath":
@ -4097,7 +4099,7 @@ function BatchCommand(text) {
if(typeof val == 'object') {
bb = val;
if(bb.width == 0 || bb.height == 0) {
canvas.setZoom(current_zoom * 2);
canvas.setZoom(current_zoom * bb.factor);
return {'zoom': current_zoom, 'bbox': bb};
}
return calcZoom(bb);