-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
83b3d64
9af534a
3fdb308
0c62890
273a4c3
e0050f7
c3c3b3a
a8fba03
66259ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
var Drawing = require('@src/components/drawing'); | ||
|
||
var d3 = require('d3'); | ||
|
||
var Plotly = require('@lib/index'); | ||
|
||
var Drawing = require('@src/components/drawing'); | ||
var createGraphDiv = require('../assets/create_graph_div'); | ||
var destroyGraphDiv = require('../assets/destroy_graph_div'); | ||
var fail = require('../assets/fail_test'); | ||
|
@@ -348,6 +345,54 @@ describe('Drawing', function() { | |
expect(g.attr('transform')).toEqual('translate(8,9) scale(4,5) translate(-8,-9) translate(1, 2)'); | ||
}); | ||
}); | ||
|
||
describe('bBox', function() { | ||
afterEach(destroyGraphDiv); | ||
|
||
it('should update bounding box dimension on window scroll', function(done) { | ||
var gd = createGraphDiv(); | ||
|
||
// allow page to scroll | ||
gd.style.position = 'static'; | ||
|
||
Plotly.plot(gd, [{ | ||
y: [1, 2, 1] | ||
}], { | ||
annotations: [{ | ||
text: 'hello' | ||
}], | ||
height: window.innerHeight * 2, | ||
width: 500 | ||
}) | ||
.then(function() { | ||
var node = d3.select('text.annotation').node(); | ||
expect(Drawing.bBox(node)).toEqual({ | ||
height: 14, | ||
width: 27.671875, | ||
left: -13.671875, | ||
top: -11, | ||
right: 14, | ||
bottom: 3 | ||
}); | ||
|
||
window.scroll(0, 200); | ||
return Plotly.relayout(gd, 'annotations[0].text', 'HELLO'); | ||
}) | ||
.then(function() { | ||
var node = d3.select('text.annotation').node(); | ||
expect(Drawing.bBox(node)).toEqual({ | ||
height: 14, | ||
width: 41.015625, | ||
left: -20.671875, | ||
top: -11, | ||
right: 20.34375, | ||
bottom: 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commit 29abb5d made the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in 3fdb308 |
||
}); | ||
}) | ||
.catch(fail) | ||
.then(done); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('gradients', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to keep the perf gains from #1585 in this fix, I'm pretty sure the only change we'd need is to call this
.getBoundingClientRect()
with eachdrawing.bBox
call, rather than caching it. But we can still cachetester
, and we can cachetest3.select('.js-reference-point').node()
.Just a question of timing really - now that you have a scrolling test in place it seems safe to me, but you can leave it as is for now if you need to move on to other things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's in #1690