-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(canvas export): regression caused by safegurading #7907
Conversation
#7866 exposed a regression when using `toCanvasElement` This commit fixes it and fixes another issue: `object.toCanvasElement()` would fire an added event which is absolutely undesired
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
canvas.add(this); | ||
var canvasEl = canvas.toCanvasElement(multiplier || 1, options); | ||
this.shadow = originalShadow; | ||
this.set('canvas', canvas); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switching from add to set('canvas') don't we miss a setCoords on the object that could be necessary for proper rendering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would add a setCoords here, just to be sure we change with something is equivalent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what about we do:
canvas._objects = [this] since this is a trash-away canvas and we avoid adding an extra options to toDataUrl?
When adding this option here:
https://github.com/fabricjs/fabric.js/pull/7907/files#diff-6748525f6b3662ac6540af0ceab4cbcd5e5d44069b54ec0b1c3d9edab1e894ecR64
Is unclear that passing the objects in, those have to have a canvas reference properly set and setCoords done.
Is just an open door for misunderstandings. let's solve it inside the object.toDataUrl function and leave the rest as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok this is good.
Regarding setCoords - why would we need it?
https://github.com/fabricjs/fabric.js/pull/7907/files#diff-de494ae6278212520cae6374e5a8eecaa8d08248ab53f6f30c167949186292caR1726
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i would needed because if the object in question has offscreen coords, it will eventually not be drawn.
Since it needs to be drawn ( the whole reason of the dataurl export ) and coords can influence a drawing skip, and since we were implicitly setting them using add, i would continue setting them.
The coords are indeed reset at the end of the function. If we don't change them, there would be at least no reason to set them again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
de494ae6278212520cae6374e5a8eecaa8d08248ab53f6f30c167949186292caR1726
skipOffscreen: false,
so it should not happen
What was the new issue? |
The new issue was that the safeguarding logic removed the canvas ref from the StaticCanvas#add method and caused a bug when using with |
yes but which is the bug ? I think it is that it would missing in the object array of the original canvas, is it that? |
Code Coverage Summary
|
Code Coverage Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ready
Code Coverage Summary
|
#7866 exposed a regression when using
toCanvasElement
This commit fixes it by working around
canvas.add
and fixes another issue:object.toCanvasElement()
would fire an added event which is absolutely undesired