pathBBox() is returning a reference rather than a copy of the cached bbox value, which means the value can be accidentally written over.
Because this function is also used internally for Element.getBBox(), it's causing weird bugs like:
console.log(paper.text(0,0,"hello").getBBox().x); // => -11 Correct!
var a = paper.text(0,0,"hello");
console.log(a.getBBox().x); // => -11 Correct!
console.log(paper.text(0,0,"hello").getBBox().x); // => -1 Wrong!
- return pth.bbox;
- return clone(pth.bbox);
Added fix from issue #543 to my fork
I ran into this same issue and I can confirm that this fix worked for me.
Will read here from now on. Encountered same issue, spent a couple days on it and come here to post fix, and it's solved :P
Thanks for fix... works great
hey Thanks for the fix :) was stuck in the same issue and alot was depending on the BBox .....
Good Job :)
And Thanks to Dimitry for a remarkable Library ... Brilliant peice of work !!
Same problem. Lost a day on this - thanks for the fix!
I lost a whole day for this too. Thanks a ton for the fix!
Thanks for the fix. Any idea when the patch will land?
@DmitryBaranovskiy It is really usefull patch, can you apply to main tree ?
Fixed very strange bugs in text placement in my code, thanks!
Also ran into this. Thanks for the fix, worked perfectly.
This patch fixed a problem I had where, when a perfectly functional operation was repeated 3 or 4 times, it would unpredictably give completely unexpected X and Y co-ordinates and send the path flying off the page. With this patch, it instantly worked perfectly.
Made my day! Thanks!
But I can't compress the library to it's size of 89kb, Closure Compiler and UglifyJS give only 124. What am I doing wrong?
Thanks a bunch for this fix!
Already merged in the code.