duocai
duocai

Reputation: 65

fabricjs disable auto move operating object to top

Upvotes: 1

Views: 1082

Answers (1)

AndreaBogazzi
AndreaBogazzi

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

Related Questions