Re-center canvas if the window is resized
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@723 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
6f5a5f1030
commit
8d5b970a61
|
@ -1221,12 +1221,8 @@ function svg_edit_setup() {
|
||||||
setResolution(x * zoom, y * zoom);
|
setResolution(x * zoom, y * zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setResolution(w, h, center) {
|
var centerCanvasIfNeeded = function() {
|
||||||
w-=0; h-=0;
|
console.log('foo');
|
||||||
$('#svgcanvas').css( { 'width': w, 'height': h } );
|
|
||||||
$('#canvas_width').val(w);
|
|
||||||
$('#canvas_height').val(h);
|
|
||||||
|
|
||||||
// this centers the canvas in the workarea if it's small enough
|
// this centers the canvas in the workarea if it's small enough
|
||||||
var wa = {w: parseInt($('#workarea').css('width')),
|
var wa = {w: parseInt($('#workarea').css('width')),
|
||||||
h: parseInt($('#workarea').css('height'))};
|
h: parseInt($('#workarea').css('height'))};
|
||||||
|
@ -1238,6 +1234,17 @@ function svg_edit_setup() {
|
||||||
if (wa.h > ca.h) {
|
if (wa.h > ca.h) {
|
||||||
$('#svgcanvas').css({'top': (wa.h-ca.h)/2});
|
$('#svgcanvas').css({'top': (wa.h-ca.h)/2});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$(window).resize( centerCanvasIfNeeded );
|
||||||
|
|
||||||
|
function setResolution(w, h, center) {
|
||||||
|
w-=0; h-=0;
|
||||||
|
$('#svgcanvas').css( { 'width': w, 'height': h } );
|
||||||
|
$('#canvas_width').val(w);
|
||||||
|
$('#canvas_height').val(h);
|
||||||
|
|
||||||
|
centerCanvasIfNeeded();
|
||||||
|
|
||||||
if(center) {
|
if(center) {
|
||||||
var w_area = $('#workarea');
|
var w_area = $('#workarea');
|
||||||
|
|
Loading…
Reference in New Issue