Skip to content

Commit 23a6cc2

Browse files
committed
Fixing errors for Firefox, where the bounding box reported by would always increase even when the window size is made smaller.
1 parent c42de30 commit 23a6cc2

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/d3.timeslider.coffee

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ class TimeSlider extends EventEmitter
5555

5656
# default options and other variables for later
5757
if @useBBox
58-
@options.width = @svg[0][0].getBBox().width
59-
@options.height = @svg[0][0].getBBox().height
58+
if @svg[0][0].getBoundingClientRect
59+
@options.width = @svg[0][0].getBoundingClientRect().width
60+
@options.height = @svg[0][0].getBoundingClientRect().height
61+
else
62+
@options.width = @svg[0][0].getBBox().width
63+
@options.height = @svg[0][0].getBBox().height
6064
else
6165
@options.width = @svg[0][0].clientWidth
6266
@options.height = @svg[0][0].clientHeight
@@ -240,9 +244,16 @@ class TimeSlider extends EventEmitter
240244
.on('resize', =>
241245
# update the width of the element and the scales
242246
svg = d3.select(@element).select('svg.timeslider')[0][0]
243-
@options.width = if @useBBox then svg.getBBox().width else svg.clientWidth
244-
@scales.x.range([0, @options.width])
245247

248+
if @useBBox
249+
if svg.getBoundingClientRect
250+
@options.width = svg.getBoundingClientRect().width
251+
else
252+
@options.width = svg.getBBox().width
253+
else
254+
@options.width = svg.clientWidth
255+
256+
@scales.x.range([0, @options.width])
246257
@redraw()
247258
)
248259

0 commit comments

Comments
 (0)