I have some elements in my canvas and they don't have a rotating point
hasRotatingPoint: false
I actually want to apply it for the entire canvas, so if I click & drag to select multiple elements and create a group I want hasRotatingPoint: false to be applied there as well.
In the example bellow it works when I select a single element, but it doesn't disable the point when I create a group.
How can I disable hasRotatingPoint for groups? (Or the entire canvas)
var fabric = window.fabric
var canvas = new fabric.Canvas('canvas', {})
var opts = {
hasRotatingPoint: false,
left: 10,
}
canvas.add(new fabric.Textbox('blahblah', { ...opts, top: 60 }))
canvas.add(new fabric.Textbox('blahblah', { ...opts, top: 100 }))
canvas.setWidth(300)
canvas.setHeight(200)
canvas {
border: 1px dashed red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.4.4/fabric.min.js"></script>
<canvas id="canvas" width="300" height="200"></canvas>
Whenever a new
ActiveSelectionis created,fabric.Canvasfires aselection:createdevent with the instance offabric.ActiveSelectionattached to it astarget. So you can listen to this event and change the selection'shasRotatingPointaccordingly.To cover the case when a user selects one object then adds another one to the selection via
Shift+click, you should also listen toselection:updatedevent, as this will resethasRotatingPointto default.If you want to make it a default behavior for all objects, you can patch
fabric.Objectprototype, since all objects (ActiveSelectionnot being an exception) are extended from it.