#1188 closed defect (fixed)
dojo.html.placeOnScreenAroundElement FIX
Reported by: | Owned by: | liucougar | |
---|---|---|---|
Priority: | blocker | Milestone: | |
Component: | HTML | Version: | 0.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
It is obvious when using the ComboBox? widget!
Reason: when the function calls for the absolute position of the node, it gets the upper-left content corner, ignoring the border and margin. Then it calls for the marginBox to get the height and width.
Therefore, when you have a border around the node this happens (e.g. BL, vertical, border: 1px, offsetTop:9px, height: 10px):
top = node's content absolute top = 10px (offsetTop + top border + top margin)
height = node's content height + horizontal borders + horizontal margins = 12px
Ends up positioning 23px from top (22px + another pixel so that they do not overlap), when in fact our node ends (content+border) at 21px from top. The new node that is positioned BL gets to be 2px away.
Fix (SVN difference from revision 5011):
Index: D:/xhosts/dentab.ro.my/www/js/dojo_nightly/src/html/util.js =================================================================== --- D:/xhosts/dentab.ro.my/www/js/dojo_nightly/src/html/util.js (revision 5011) +++ D:/xhosts/dentab.ro.my/www/js/dojo_nightly/src/html/util.js (working copy) @@ -381,7 +381,7 @@ aroundNode = dojo.byId(aroundNode); var oldDisplay = aroundNode.style.display; aroundNode.style.display=""; - var mb = dojo.html.getMarginBox(aroundNode); + var mb = dojo.html.getContentBox(aroundNode); var aroundNodeW = mb.width; var aroundNodeH = mb.height; var aroundNodePos = dojo.html.getAbsolutePosition(aroundNode, true); @@ -394,6 +394,24 @@ desiredX = aroundNodePos.x + (nodeCorner.charAt(1)=='L' ? 0 : aroundNodeW); desiredY = aroundNodePos.y + (nodeCorner.charAt(0)=='T' ? 0 : aroundNodeH); + //add or extract the border and margin, according to the node's corner + if (nodeCorner.charAt(1)=='L') + { + desiredX -= dojo.html.getBorderExtent(aroundNode, "left") + dojo.html.getMarginExtent(aroundNode, "left"); + } + else + { + desiredX += dojo.html.getBorderExtent(aroundNode, "right") + dojo.html.getMarginExtent(aroundNode, "right"); + } + if (nodeCorner.charAt(0)=='T') + { + desiredY -= dojo.html.getBorderExtent(aroundNode, "top") + dojo.html.getMarginExtent(aroundNode, "top"); + } + else + { + desiredY += dojo.html.getBorderExtent(aroundNode, "bottom") + dojo.html.getMarginExtent(aroundNode, "bottom"); + } + pos = dojo.html.placeOnScreen(node, desiredX, desiredY, padding, hasScroll, corners, true); if(pos.dist == 0){ best = pos;
Change History (6)
comment:1 Changed 15 years ago by
Owner: | changed from Bryan Forbes to liucougar |
---|
comment:2 Changed 15 years ago by
I have just found out what is CLA, through the dojo-interest mailing list.
I will need to send the CLA by snail mail to the Dojo Foundation, right? and then code pieces will be liable to be included in the main trunk?
comment:5 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Do you have CLA on file please?