版本2.3.6
重现步骤:
- 点击“全选”,选择正确。
- 接下来点击“设置缩放为1.5”,
- 然后再点击“全选”,
结果:现在选择边框不正确。
$(document).ready(function() {
var canvas = new fabric.Canvas('canvas');
canvas.add(new fabric.Rect({
left: 50,
top: 50,
width: 75,
height: 50,
fill: 'green',
stroke: 'black',
strokeWidth: 3,
padding: 10
}));
canvas.add(new fabric.Circle({
left: 120,
top: 120,
radius: 30,
fill: 'gray',
stroke: 'black',
strokeWidth: 3
}));
$("#select-all").click(function() {
canvas.discardActiveObject();
var elements = canvas.getObjects();
var selection = new fabric.ActiveSelection(elements);
canvas.setActiveObject(selection);
canvas.requestRenderAll();
});
$("#set-zoom-15").click(function() {
canvas.setZoom(1.2);
});
$("#set-zoom-10").click(function() {
canvas.setZoom(1.0);
});
canvas.renderAll();
});
canvas {
border: 1px solid #ccc;
margin-top: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.3.6/fabric.min.js"></script>
<input id="select-all" type="button" value="select all" />
<input id="set-zoom-15" type="button" value="set zoom as 1.5" />
<input id="set-zoom-10" type="button" value="set zoom as 1" />
<canvas id="canvas" width="400" height="400" style="border:1px solid red" />
期望结果:
当缩放比例为1.5时,选择正常工作(例如缩放比例为1)。
实际情况:
当缩放比例为1.5时,选择不正确。