pathBBox() returns reference to cached bbox #543

Closed
motownread opened this Issue Mar 21, 2012 · 14 comments

Projects

None yet
@motownread

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!
a.translate(10,0);
console.log(paper.text(0,0,"hello").getBBox().x); // => -1 Wrong!

Simple fix:

-            return pth.bbox;
-           return clone(pth.bbox);
@alerizzo alerizzo added a commit to alerizzo/raphael that referenced this issue Mar 22, 2012
@alerizzo alerizzo Added fix from issue #543 to my fork dcdb673
@emezeske

I ran into this same issue and I can confirm that this fix worked for me.

@trokster

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
+1

@m1ch4ls
m1ch4ls commented May 17, 2012

Thanks for fix... works great

@Aukhan
Aukhan commented May 30, 2012

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 !!

@awcab
awcab commented Jun 21, 2012

Same problem. Lost a day on this - thanks for the fix!

@kentz
kentz commented Jun 29, 2012

I lost a whole day for this too. Thanks a ton for the fix!

@hoaproject

Thanks for the fix. Any idea when the patch will land?

@zba
zba commented Aug 6, 2012

@DmitryBaranovskiy It is really usefull patch, can you apply to main tree ?

@jdb8
jdb8 commented Aug 7, 2012

Fixed very strange bugs in text placement in my code, thanks!

@ghost
ghost commented Sep 4, 2012

Also ran into this. Thanks for the fix, worked perfectly.

@alanomaly

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.

@rodweb
rodweb commented Feb 8, 2013

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?

@martintajur

Thanks a bunch for this fix!

@tomasAlabes
Collaborator

Already merged in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment