Raphael.js Function Getbbox Give Back Nan/nan/nan In Ie8
Solution 1:
i found a workaround solution from this answer to the question "Raphael JS and Text positioning"
If i use _getBBox()
instead of getBBox()
everything is working in ie 8 also.
_getBBox() is undocumented but used internally by Raphael itself, and it works!
Solution 2:
I had the same problem in Rapahel 2.2.0 and 2.2.1, and using ._getBBox()
didn't fix it for me.
What did fix it for me is falling back to .auxGetBBox()
if it's defined and regular .getBBox()
doesn't work, like this:
var bbox = path.getBBox( );
// Workaround for apparent bug in Raphael's VML module's getBBox() overrideif( isNaN( bbox.x ) && path.auxGetBBox ){
bbox = path.auxGetBBox();
}
I don't have a fix for the underlying bug, but I have found the source of it.
In VML mode, Raphael takes the initial getBBox()
function, saves it as auxGetBBox()
on the element prototype, then replaces it with a function that appears to be broken.
It has calculations based on a variable defined as var z = 1/this.paper._viewBoxShift.scale;
, which clearly expects _viewBoxShift.scale to be some factor of the scale of the current viewbox compared to the initial viewbox , but actually _viewBoxShift.scale
is an object like this which appears to come from paperproto.getSize()
:
{ height: someNumber, width: someNumber }
This is where all the NaN
s are coming from. Cannae divide by an object.
So this workaround works fine if no zoom is applied using a viewbox, but may give incorrect results if a zoom has been applied (something I can't get to work at all in recent versions of raphael in VML mode, but that's a seperate question). Fixing that will involve digging deep into Raphael's VML module to pipe a proper zoom factor into this z
variable.
Post a Comment for "Raphael.js Function Getbbox Give Back Nan/nan/nan In Ie8"