Pedro Jose
Pedro Jose

Reputation: 442

get scaled width on object:scaling

I want to get the real object width and height while I am scaling the object. I tried with

canvas.on('object:scaling', function(e){
  console.log(e.target.width*e.target.scaleX);
});

But seem that does not work properly.

Upvotes: 2

Views: 2575

Answers (1)

Durga
Durga

Reputation: 15604

Use object.getScaledWidth().

DEMO

var canvas = new fabric.Canvas("c");
var circle = new fabric.Circle({radius:100})
canvas.add(circle);
circle.on('scaling',function(){
 console.log(parseInt(this.getScaledWidth()))
})
canvas{
  border: 1px dotted green;
}
<script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script>
<canvas id="c" width=400 height=400></canvas>

Upvotes: 9

Related Questions