Skip to content

Commit

Permalink
Use getBBox instead of getClientRects.
Browse files Browse the repository at this point in the history
After some browser testing and a closer reading of the CSSOM specification, it
turns out Firefox was correctly reporting the size of the tight SVG bounding
box, while WebKit was returning (incorrectly) the size of the SVG container. We
now use `rect.getBBox` on all browsers, which is much more reliable!
  • Loading branch information
mbostock committed Sep 21, 2010
1 parent 9124266 commit 8791129
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 73 deletions.
16 changes: 4 additions & 12 deletions polymaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if (!org) var org = {};
if (!org.polymaps) org.polymaps = {};
(function(po){

po.version = "2.2.0"; // semver.org
po.version = "2.2.0+1"; // This fork not semver!

var zero = {x: 0, y: 0};
po.ns = {
Expand Down Expand Up @@ -514,17 +514,9 @@ po.map = function() {

map.resize = function() {
if (!size) {
/*
* Firefox does not correctly report the dimensions of SVG elements.
* However, it does correctly report the size of the child rect!
*/
var e = container.ownerSVGElement || container;
if (e.offsetWidth == null) {
rect.setAttribute("width", "100%");
rect.setAttribute("height", "100%");
e = rect;
}
b = e.getClientRects()[0];
rect.setAttribute("width", "100%");
rect.setAttribute("height", "100%");
b = rect.getBBox();
sizeActual = {x: b.width, y: b.height};
resizer.add(map);
} else {
Expand Down
Loading

0 comments on commit 8791129

Please sign in to comment.