Reputation: 1025
I'm trying to figure out how to grab a fabric object and change its properties when its moving. I have three different shapes. A fabric.Rect, fabric.Circle and fabric.Triangle. They all have different property values so if anyone knows how to change them accordingly that would be greatly appreciated.
This is how I tried doing it with no success.
canvas.on('object:moving', function(e) {
var activeObject = e.target;
activeObject.shadow = null;
if (e.target = fabric.Rect){
activeObject.height = 40;
activeObject.width = 40;
};
if (e.target = fabric.Circle){
activeObject.radius = 20;
};
if (e.target = fabric.Triangle){
activeObject.height = 40;
activeObject.width = 35
};
});
Upvotes: 0
Views: 1822
Reputation: 761
function onObjectSelected(e) {
console.log(e.target.get('type'));
}
canvas.on('object:selected', onObjectSelected);
Upvotes: 2