defaultExtent not working in firefox
ldegen opened this issue · 3 comments
The current way of calculating the defaultExtent
looks like this:
function defaultExtent() {
var svg = this.ownerSVGElement || this;
return [[0, 0], [svg.width.baseVal.value, svg.height.baseVal.value]];
}
In Chrome this works fine, but it seems that this does not work in firefox (and some mobile browsers aswell?), because svg.width
and svg.height
do not work as expected.
This causes my brush to not receive any mouse events at all (the overlay rect has dimensions 1x1 px).
FYI: In my case, I can get away with just hard-wiring the extent to something "big enough".
I tested this in Firefox, and this is a fairly basic feature of SVG. Are you using an old version of Firefox? Are you not setting with the width and height of your SVG explicitly (which is required)? Do you have an example on bl.ocks.org or similar that demonstrates the issue? What is the resulting computed extent that you are seeing?
my firefox reports version 45.2.0.
I assume by "explicit" you mean in pixels rather than percentage?
Right now, width and height of the SVG are set to "100%" via CSS rule.
This may in fact be the problem, I haven't thought of that, thanks.
I will have another look during the weekend and report back.
Right. You can set width and height CSS properties to control how much space the SVG element takes up on the page, but even if you do that, you also need to set the width and height attributes on the SVG element to fix the coordinate system. (Alternatively you can use the viewBox attribute, but that isn’t supported by the default implementation of brush.extent.)
I’ll change the documentation to note that the default implementation requires these attributes. As you discovered you can also set the extent explicitly or substitute a different implementation.