I have a page that allows you to insert an image inside the canvas element and it works perfectly.
Now, what I need is a way to limit the positioning of the image inside the canvas, not allowing any remaining white space, regardless of the positioning of the image.
The image selection option is active. The repositioning is done using drag and drop.
Ineedsomethinglikethisfromthe link , but without having to zoom in to move the image.
Canvas
<canvas id="c" height="300" width="200"></canvas>
Image
<img id="imagem" src="images/teste.jpg">
JS
var c = new fabric.Canvas('c');
var imageSrc = "images/teste.jpg";
fabric.Image.fromURL(imageSrc, function(img) {
img.scaleToWidth(c.getWidth());
img.scaleToHeight(c.getHeight());
img.set('selectable', true);
img.set('hasControls', false);
c.add(img);
});