renciso218 / blockly

Automatically exported from code.google.com/p/blockly
0 stars 0 forks source link

Right click doesn't open the context menu close to the block on IE #165

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. drop a block
2. right click

What is the expected output? What do you see instead?

the context menu should appear close to the block

instead if appears at 0, 0.

this is related to issue 164, because scrollX/Y is used to calculate where to 
put the context menu.

this patch fixes the issue:

 svn diff utils.js 
Index: utils.js
===================================================================
--- utils.js    (revision 1380)
+++ utils.js    (working copy)
@@ -288,8 +288,8 @@
  */
 Blockly.convertCoordinates = function(x, y, toSvg) {
   if (toSvg) {
-    x -= window.scrollX;
-    y -= window.scrollY;
+    x -= window.scrollX || window.pageXOffset;
+    y -= window.scrollY || window.pageYOffset;
   }
   var svgPoint = Blockly.svg.createSVGPoint();
   svgPoint.x = x;
@@ -300,8 +300,8 @@
   }
   var xy = svgPoint.matrixTransform(matrix);
   if (!toSvg) {
-    xy.x += window.scrollX;
-    xy.y += window.scrollY;
+    xy.x += window.scrollX || window.pageXOffset;
+    xy.y += window.scrollY || window.pageYOffset;
   }
   return xy;
 };
@@ -313,8 +313,11 @@
  * @return {!Object} Object with .x and .y properties.
  */
 Blockly.mouseToSvg = function(e) {
-  return Blockly.convertCoordinates(e.clientX + window.scrollX,
-      e.clientY + window.scrollY, true);
+  var scrollX = window.scrollX || window.pageXOffset,
+      scrollY = window.scrollY || window.pageYOffset;
+
+  return Blockly.convertCoordinates(e.clientX + scrollX,
+      e.clientY + scrollY, true);
 };

 /**

Please use labels and text to provide additional information.

Original issue reported on code.google.com by luismarianoguerra@gmail.com on 27 Sep 2013 at 9:52

GoogleCodeExporter commented 8 years ago
Fixed in r1389.  Thanks for the patch!

Original comment by neil.fra...@gmail.com on 30 Sep 2013 at 10:16