How can I pan and zoom using fabricjs? I\'ve tried using the methods zoomToPoint and setZoom but they do not work for panning. Once I start using different zoom points I sta
I know it is already answered, but I had to do a mouse panning, so I adapted the fiddle of the accepted answer to do so. I post it here for anyone who has to do something like this. This is just the main idea:
var panning = false;
canvas.on('mouse:up', function (e) {
panning = false;
});
canvas.on('mouse:down', function (e) {
panning = true;
});
canvas.on('mouse:move', function (e) {
if (panning && e && e.e) {
var units = 10;
var delta = new fabric.Point(e.e.movementX, e.e.movementY);
canvas.relativePan(delta);
}
});
Here is the fiddle: http://jsfiddle.net/gncabrera/hkee5L6d/5/