Fixed issue 360, allows panning with middle mouse button or left mouse button while holding spacebar

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1494 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Alexis Deveria
2010-04-01 16:00:50 +00:00
parent edae9befd9
commit 363b456431
2 changed files with 41 additions and 0 deletions

View File

@@ -1417,6 +1417,44 @@
return true;
};
(function() {
var last_x = null, last_y = null, w_area = workarea[0],
panning = false, keypan = false;
$('#svgcanvas').bind('mousemove mouseup', function(evt) {
if(panning === false) return;
w_area.scrollLeft -= (evt.clientX - last_x);
w_area.scrollTop -= (evt.clientY - last_y);
last_x = evt.clientX;
last_y = evt.clientY;
if(evt.type === 'mouseup') panning = false;
return false;
}).mousedown(function(evt) {
if(evt.button === 1 || keypan === true) {
panning = true;
last_x = evt.clientX;
last_y = evt.clientY;
return false;
}
});
$(window).mouseup(function() {
panning = false;
});
$(document).bind('keydown', 'space', function(evt) {
svgCanvas.spaceKey = keypan = true;
evt.preventDefault();
}).bind('keyup', 'space', function(evt) {
evt.preventDefault();
svgCanvas.spaceKey = keypan = false;
});
}());
(function() {
var button = $('#main_icon');
var overlay = $('#main_icon span');

View File

@@ -2852,6 +2852,7 @@ function BatchCommand(text) {
// and do nothing else
var mouseDown = function(evt)
{
if(evt.button === 1 || canvas.spaceKey) return;
root_sctm = svgcontent.getScreenCTM().inverse();
var pt = transformPoint( evt.pageX, evt.pageY, root_sctm ),
mouse_x = pt.x * current_zoom,
@@ -3197,6 +3198,7 @@ function BatchCommand(text) {
var mouseMove = function(evt)
{
if (!started) return;
if(evt.button === 1 || canvas.spaceKey) return;
var selected = selectedElements[0],
pt = transformPoint( evt.pageX, evt.pageY, root_sctm ),
mouse_x = pt.x * current_zoom,
@@ -3494,6 +3496,7 @@ function BatchCommand(text) {
var mouseUp = function(evt)
{
if(evt.button === 1) return;
var tempJustSelected = justSelected;
justSelected = null;
if (!started) return;