-
-
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
fabricjs call to canvas.toDataURL() resizes the dimensions of the canvas #4252
Comments
Hello, i answered your question on stackoverflow. there are 2 things to take in account: who does not resize the canvas can use the same logic is in place now with a simple fix. who resize the canvas can as well use the current logic adding backstore dimensions only resize, fixing the problem but at cost of an unefficent twice resize and cache invalidation. so a simple fix is very simple and consist of adding the backstoreOnly true to the 2 resizes in the toDataUrlWithMultiplier function if you want to give it a shot. |
adds the backstoreOnly to __toDataURLWithMultiplier's setDimensions calls to prevent the canvas from resizing in the browser window when the canvas.toDataURL() method is called per issue fabricjs#4252
@asturur - that fixed the issue. Thank you! |
adds the backstoreOnly to __toDataURLWithMultiplier's setDimensions calls to prevent the canvas from resizing in the browser window when the canvas.toDataURL() method is called per issue #4252
adds the backstoreOnly to __toDataURLWithMultiplier's setDimensions calls to prevent the canvas from resizing in the browser window when the canvas.toDataURL() method is called per issue fabricjs#4252
I've posted this behavior on stackoverflow here: https://stackoverflow.com/questions/45908772/fabricjs-call-to-canvas-todataurl-resizes-the-dimensions-of-the-canvas
and per @asturur answer I'm creating an issue for the bug.
I'm using fabricjs 1.7.17 and have seen this issue below on IE Edge, Chrome and Firefox.
where the canvas is being set with a width and height in HTML of 768px.
Within my fabricjs canvas init I've got:
The problem is when you call the editor.canvas.toDataURL() method the size of the goes from 768px to 1080px
If you call the browser's native canvas.toDataURL() method there isn't a jump in size.
Anyone bump into this and have a possible fix?
Here's a simplified jsfiddle: https://jsfiddle.net/m8dhmbtu/23/
Click on the "Native Canvas.toDataURL()" and you'll get the results to console.log and there will be no change to the displayed canvas in the preview window.
Click on the "Fabricjs canvas.toDataURL()" and you'll also get the results (the same correct png data) to console.log however; you'll also get a jump in the size of the in the preview window...this is what I'm trying to prevent.
The text was updated successfully, but these errors were encountered: