Reputation: 335
I am trying to implement a point zoom in fabric.js and was busy writing my own code to do this. Then I noticed in the fabric.js doc that there is a zoomToPoint function:
http://fabricjs.com/docs/fabric.Canvas.html
But I am unable to get it working with this simple code:
var zoom = Math.pow(1 + Math.abs(event.deltaY)/2 , event.deltaY > 0 ? 1 : -1);
var zoomPoint = new fabric.Point(event.pageX, event.pageY);
console.log(canvas);
canvas.zoomToPoint(zoomPoint, zoom);
canvas.renderAll();
I am using the mousewheel jquery plugin and it is working perfectly with my custom code (although I am having some object position errors). I even check in the console that my canvas is not undefined.
Any help would be appreciated.
Upvotes: 2
Views: 1002
Reputation: 335
I was using the CDNJS link on the website, which was only version 1.4.0
Did not think it was a couple of versions old.
Upvotes: 2