]> git.openstreetmap.org Git - rails.git/commitdiff
Firefox-friendly calculation of dragstart offset
authorRichard Fairhurst <richard@systemeD.net>
Sun, 9 Mar 2014 21:29:48 +0000 (21:29 +0000)
committerRichard Fairhurst <richard@systemeD.net>
Sun, 9 Mar 2014 21:29:48 +0000 (21:29 +0000)
(personally I am not feeling very Firefox-friendly right now)

app/assets/javascripts/index.js

index e5f6fe47811a4f275f4814a0a7267dc5cee9b3f6..2b5f23ef17d2f9487956d7332eb4e90603c49048 100644 (file)
@@ -361,8 +361,10 @@ $(document).ready(function () {
     $(".routing_marker").on('dragstart',function(e) {
       e.originalEvent.dataTransfer.effectAllowed = 'move';
       e.originalEvent.dataTransfer.setData('id', this.id);
     $(".routing_marker").on('dragstart',function(e) {
       e.originalEvent.dataTransfer.effectAllowed = 'move';
       e.originalEvent.dataTransfer.setData('id', this.id);
-      e.originalEvent.dataTransfer.setData('offsetX', e.originalEvent.target.width/2 - (e.originalEvent.x-e.target.x));
-      e.originalEvent.dataTransfer.setData('offsetY', e.originalEvent.target.height  - (e.originalEvent.y-e.target.y));
+      var xo=e.originalEvent.clientX - $(e.target).offset().left;
+      var yo=e.originalEvent.clientY - $(e.target).offset().top;
+      e.originalEvent.dataTransfer.setData('offsetX', e.originalEvent.target.width/2 - xo);
+      e.originalEvent.dataTransfer.setData('offsetY', e.originalEvent.target.height  - yo);
     });
   });
 
     });
   });