Opened 13 years ago

Closed 12 years ago

#1125 closed enhancement (invalid)

[patch][cla] dojo.html.overElement() fails for span

Reported by: guest Owned by: Bryan Forbes
Priority: high Milestone: 1.0
Component: General Version: 0.3
Keywords: Cc: hannes.wyss@…, markus.huggler@…
Blocked By: Blocking:

Description

Hi

when an inline-element is wrapped, there are cases when html.overElement erroneously returns false. Our setup: we have a longish text, with tooltip-enabled spans:

[...] 
summer belongs to Greece. September: Develops «Morphoride», a bus map 
through Morphopolis with 32 bus-stops visualized as Panoramas on canvas 
and as quick time movies. October: He finishes Morphopolis and 
Morphoride. Travels to China. Meets his friend 
<SPAN class="blue" id="connect-8-5">
  Dieter Zimmer
  <A href="http://new.davaz.com/en/tooltip/tooltip/artobject_id/1185" dojoType="tooltip" toggleDuration="500" toggle="fade" connectId="connect-8-5" style="display: none">
  </A>
</SPAN>
, professor for industrial design 
[...]

some of them end up being wrapped. Holding the mouse over the lower (wrapped) part of the span does nothing, while positioning the mouse above and scrolling down (using the arrow-keys) works, because no onMouseMove-events are triggered.

We have found that this is because html.overElement does not deal with wrapped inline elements.

Here is a proposed Fix, which does not solve all problems (there is still an area to the right of the upper part of the wrapped element where html.overElement returns true, and elements that are not wrapped have a similar problem on the left side), but works well enough for our needs:

--- src/html.js 2006-06-12 23:18:26.000000000 +0200
+++ src/html.js 2006-07-13 16:22:56.434106957 +0200
@@ -497,13 +497,30 @@

  with(dojo.html){
    var top = getAbsoluteY(element, true);
-   var bottom = top + getInnerHeight(element);
+    var height = getInnerHeight(element);
+   var bottom = top + height;
    var left = getAbsoluteX(element, true);
-   var right = left + getInnerWidth(element);
+    var width = getInnerWidth(element);
+   var right = left + width;
  }

- return (mouse.x >= left && mouse.x <= right &&
+  var result = (mouse.x >= left && mouse.x <= right &&
    mouse.y >= top && mouse.y <= bottom);
+
+  if(result) return true;
+
+  // Check whether we are hovering over the lower part
+  // of a wrapped inline element:
+  var prnt = element.parentNode;
+  if(prnt) {
+    left = dojo.html.getAbsoluteX(prnt, true);
+    height = height / 2.0;
+    top += height;
+    right = left + width;
+    result = (mouse.x >= left && mouse.x <= right &&
+      mouse.y >= top && mouse.y <= bottom);
+  }
+  return result;
 }

 dojo.html.setActiveStyleSheet = function(title){

See the setup and a patched 0.3.1 in action: http://new.davaz.com/en/personal/life/pretty

I'll get my signed ICLA on the fax tonight hopefully,

TIA

Hannes & Maege

Change History (5)

comment:1 Changed 13 years ago by dylan

Milestone: 0.4
Owner: changed from anonymous to Bryan Forbes
Summary: html.overElement fails for wrapped part of inline element.[patch] html.overElement fails for wrapped part of inline element.

CLA on file.

comment:2 Changed 13 years ago by dylan

Milestone: 0.40.4.1
Summary: [patch] html.overElement fails for wrapped part of inline element.[patch][cla] html.overElement fails for wrapped part of inline element.

comment:3 Changed 13 years ago by bill

Milestone: 0.4.10.6
Summary: [patch][cla] html.overElement fails for wrapped part of inline element.[patch][cla] dojo.html.overElement() fails for span
Type: defectenhancement

Yes, that function is only meant to work for block elements. I will update the code comment to match. Leaving this bug open as an enhancement request.

comment:4 Changed 13 years ago by bill

(In [6295]) fix comment to match actual functionality (references #1125)

comment:5 Changed 12 years ago by Bryan Forbes

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.