Setting FabricJS Canvas Dimensions with Buttons
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I have a responsive FabricJS canvas and I'm wondering if it's possible to "toggle", for the lack of a better word, the dimensions from "fluid" to being a square.

Here is what I have currently: http://jsfiddle.net/code4ever/r9mbvtw0/

How might I achieve this? Please let me know if I can answer any questions that will help you produce a solution.

Thanks,

sharper

awarded to quillford

Crowdsource coding tasks.

1 Solution

Winning solution
Tipped

here you go. this just finds which dimension, width or height, is smaller and makes that the size of the side of the square. http://jsfiddle.net/xoh6g1p8/

i added a variable so that it the fluid/square selection will persist after resizing.
quillford 3 months ago
here's the link for that http://jsfiddle.net/zpvh2mfg/1/
quillford 3 months ago
This looks great, thanks! Would you be interested in tinkering with it further for a tip? I'm interested in having it remain square if the window is resized (if it was set to square), but fluid if the window is resized (if it's set to fluid, the default). Thanks again
sharper 3 months ago
this should do it http://jsfiddle.net/zpvh2mfg/1/
quillford 3 months ago
Looks great, thank you
sharper 3 months ago