I have a fabric.js canvas on my page, that I'd like to be responsive. My code works for scaling the canvas itself, but not the objects I've drawn on it. Any idea? I've searched SO but couldn't find a solution that worked for me.
var resizeCanvas;
resizeCanvas = function() {
var height, ratio, width;
ratio = 800 / 1177;
width = tmpl.$('.canvas-wrapper').width();
height = width / ratio;
canvas.setDimensions({
width: width,
height: height
});
};
Meteor.setTimeout(function() {
return resizeCanvas();
}, 100);
$(window).resize(resizeCanvas);
Here's my zoom function - We zoom the canvas, and then loop over all objects and scale them as well.
Call like
zoomIt(2.2)