Module: nagvis Branch: master Commit: f38875a3a14d3f42ebfef16e97feeda2205acf6e URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=f38875a3a14d3f42ebfef16e97feeda2205acf6e
Author: Lars Michelsen <[email protected]> Date: Fri Apr 23 20:08:11 2010 +0200 Recognizing grid when adding new objects --- share/frontend/wui/js/wui.js | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/share/frontend/wui/js/wui.js b/share/frontend/wui/js/wui.js index 9cdafde..1624c2e 100644 --- a/share/frontend/wui/js/wui.js +++ b/share/frontend/wui/js/wui.js @@ -277,6 +277,13 @@ function get_click_pos(e) { viewType = 'icon'; } + // When a grid is enabled align the dragged object in the nearest grid + if(oViewProperties.grid_show === 1) { + var aCoords = coordsToGrid(posx, posy); + posx = aCoords[0]; + posy = aCoords[1]; + } + // Save current click position coords = coords + posx + ',' + posy + ','; @@ -364,6 +371,13 @@ function saveObjectAfterResize(oObj) { oResult = null; } +function coordsToGrid(x, y) { + var gridMoveX = x - (x % oViewProperties.grid_steps); + y = y + getHeaderHeight(); + var gridMoveY = y - (y % oViewProperties.grid_steps); + return [ gridMoveX, gridMoveY ]; +} + function saveObjectAfterMoveAndDrop(oObj) { // Reset z-index to configured value oObj.setZ(oObj.defz); @@ -381,11 +395,8 @@ function saveObjectAfterMoveAndDrop(oObj) { // When a grid is enabled align the dragged object in the nearest grid if(oViewProperties.grid_show === 1) { - var gridMoveX = oObj.x - (oObj.x % oViewProperties.grid_steps); - y = oObj.y + getHeaderHeight(); - var gridMoveY = y - (y % oViewProperties.grid_steps); - - oObj.moveTo(gridMoveX, gridMoveY); + var coords = coordsToGrid(oObj.x, oObj.y); + oObj.moveTo(coords[0], coords[1]); } // Split id to get object information ------------------------------------------------------------------------------ _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
