Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Drawing bbox fix for window scroll #1683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 16, 2017
Prev Previous commit
Next Next commit
cache ref to tester div and tester ref on drawing module object
- so that Drawing.bBox does not have to query the DOM
  to fing them on every call.
  • Loading branch information
etpinard committed May 15, 2017
commit 0c62890b6f04e87201c921581d9c9d8abc193f2e
21 changes: 12 additions & 9 deletions 21 src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,16 +579,17 @@ drawing.makeTester = function(gd) {
tester.node()._cache = {};
}

gd._tester = tester;
gd._testref = testref;
drawing.tester = gd._tester = tester;
drawing.testref = gd._testref = testref;
};

// use our offscreen tester to get a clientRect for an element,
// in a reference frame where it isn't translated and its anchor
// point is at (0,0)
// always returns a copy of the bbox, so the caller can modify it safely
var savedBBoxes = [],
maxSavedBBoxes = 10000;
var savedBBoxes = [];
var maxSavedBBoxes = 10000;

drawing.bBox = function(node) {
// cache elements we've already measured so we don't have to
// remeasure the same thing many times
Expand All @@ -597,22 +598,24 @@ drawing.bBox = function(node) {
return Lib.extendFlat({}, savedBBoxes[saveNum.value]);
}

var test3 = d3.select('#js-plotly-tester'),
tester = test3.node();
var tester3 = drawing.tester;
var tester = tester3.node();

// copy the node to test into the tester
var testNode = node.cloneNode(true);
tester.appendChild(testNode);

// standardize its position... do we really want to do this?
d3.select(testNode).attr({
x: 0,
y: 0,
transform: ''
});

var testRect = testNode.getBoundingClientRect(),
refRect = test3.select('.js-reference-point')
.node().getBoundingClientRect();
var testRect = testNode.getBoundingClientRect();
var refRect = drawing.testref
.node()
.getBoundingClientRect();

tester.removeChild(testNode);

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.