Reputation: 65
moveTo
to finish my requirement,but I want use some new feature in new version.Upvotes: 1
Views: 1082
Reputation: 14731
there is a preserveObjectStacking property, that should be default to false, that should do exactly what you need. I guess that maybe 1.5 had a bug and was not working correctly?
http://fabricjs.com/docs/fabric.Canvas.html
Search for preserveObjectStacking in that page.
var _canvas = new fabric.Canvas('canvas', { preserveObjectStacking: true });
var text1 = new fabric.Text('word one...')
var text2 = new fabric.Text('word two...', {
top: 30,
left: 40,
backgroundColor: '#f00'
})
_canvas.add(text1)
_canvas.add(text2)
#canvas {
width: 400px;
height: 400px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.7.17/fabric.min.js"></script>
<canvas id="canvas"></canvas>
Upvotes: 2