mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-21 19:26:41 +02:00
Add copyBox to copy immutable ClientRects
bc we do things like `box.height -= something` to trim box to window
This commit is contained in:
+18
-3
@@ -53,10 +53,9 @@ export function uiCurtain() {
|
||||
|
||||
curtain.reveal = function(box, text, options) {
|
||||
if (typeof box === 'string') box = d3.select(box).node();
|
||||
if (box.getBoundingClientRect) box = box.getBoundingClientRect();
|
||||
if (box.getBoundingClientRect) box = copyBox(box.getBoundingClientRect());
|
||||
|
||||
options = options || {};
|
||||
curtain.cut(box, options.duration);
|
||||
|
||||
if (text) {
|
||||
// pseudo markdown bold text hack
|
||||
@@ -90,7 +89,7 @@ export function uiCurtain() {
|
||||
}
|
||||
|
||||
// var dimensions = utilGetDimensions(selection, true),
|
||||
var tip = tooltip.node().getBoundingClientRect(),
|
||||
var tip = copyBox(tooltip.node().getBoundingClientRect()),
|
||||
w = window.innerWidth,
|
||||
h = window.innerHeight,
|
||||
tooltipWidth = 200,
|
||||
@@ -173,6 +172,8 @@ export function uiCurtain() {
|
||||
.call(uiToggle(false));
|
||||
}
|
||||
|
||||
curtain.cut(box, options.duration);
|
||||
|
||||
return tooltip;
|
||||
};
|
||||
|
||||
@@ -215,5 +216,19 @@ export function uiCurtain() {
|
||||
};
|
||||
|
||||
|
||||
// ClientRects are immutable, so copy them to an object,
|
||||
// in case we need to trim the height/width.
|
||||
function copyBox(src) {
|
||||
return {
|
||||
top: src.top,
|
||||
right: src.right,
|
||||
bottom: src.bottom,
|
||||
left: src.left,
|
||||
width: src.width,
|
||||
height: src.height
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return curtain;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user