diff options
author | Madhura Jayaratne <madhura.cj@gmail.com> | 2013-01-19 04:59:37 +0400 |
---|---|---|
committer | Madhura Jayaratne <madhura.cj@gmail.com> | 2013-01-19 04:59:37 +0400 |
commit | b85d8b7fcc15661caec930d3c08e26e0027451a7 (patch) | |
tree | d36fcaef467603c3c5f39de01f672b1e79272013 /js/tbl_gis_visualization.js | |
parent | 60e83586836ed9f58b6ac80d159fe962f0eec991 (diff) |
Chrome has removed layerX and layerY from the event object
Diffstat (limited to 'js/tbl_gis_visualization.js')
-rw-r--r-- | js/tbl_gis_visualization.js | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/js/tbl_gis_visualization.js b/js/tbl_gis_visualization.js index 7df0f82596..2e0ab1466c 100644 --- a/js/tbl_gis_visualization.js +++ b/js/tbl_gis_visualization.js @@ -155,6 +155,14 @@ function initGISVisualization() { zoomAndPan(); } +function getRelativeCoords(e) { + var position = $('#placeholder').offset(); + return { + x : e.pageX - position.left, + y : e.pageY - position.top + }; +} + /** * Ajax handlers for GIS visualization page * @@ -208,19 +216,20 @@ AJAX.registerOnload('tbl_gis_visualization.js', function() { }); $('#placeholder').live('mousewheel', function(event, delta) { + var relCoords = getRelativeCoords(event); if (delta > 0) { //zoom in scale *= 1.5; - // zooming in keeping the position under mouse pointer unmoved. - x = event.layerX - (event.layerX - x) * 1.5; - y = event.layerY - (event.layerY - y) * 1.5; + // zooming in keeping the position under mouse pointer unmoved. + x = relCoords.x - (relCoords.x - x) * 1.5; + y = relCoords.y - (relCoords.y - y) * 1.5; zoomAndPan(); } else { //zoom out scale /= 1.5; // zooming out keeping the position under mouse pointer unmoved. - x = event.layerX - (event.layerX - x) / 1.5; - y = event.layerY - (event.layerY - y) / 1.5; + x = relCoords.x - (relCoords.x - x) / 1.5; + y = relCoords.y - (relCoords.y - y) / 1.5; zoomAndPan(); } return true; @@ -250,8 +259,9 @@ AJAX.registerOnload('tbl_gis_visualization.js', function() { $('#placeholder').live('dblclick', function(event) { scale *= 1.5; // zooming in keeping the position under mouse pointer unmoved. - x = event.layerX - (event.layerX - x) * 1.5; - y = event.layerY - (event.layerY - y) * 1.5; + var relCoords = getRelativeCoords(event); + x = relCoords.x - (relCoords.x - x) * 1.5; + y = relCoords.y - (relCoords.y - y) * 1.5; zoomAndPan(); }); |