var json = '{"objects":
[{"type":"rect","originX":"center","originY":"center","left":300,"top":150,"width"
:150,"height":150,"fill":"#29477F","overlayFill":null,"stroke":null,"strokeWidth":
1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMi
terLimit":10,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity"
:1,"shadow":{"color":"rgba(94, 128, 191, 0.5)","blur":5,"offsetX":10,"offsetY":10},"visible":true,"clipTo":null,"rx":0,"ry"
:0,"x":0,"y":0}
我的json包含2个对象,我的目的是使第一个对象始终可以/不可移动,如何实现这一目标?这是我尝试过的,我需要使用loadFromJSON。
var objectx = canvas.getObjects().length; //get all object length;
objectx[1].selectable = false; //make object unselectable;
这是我的DEMO
答案 0 :(得分:1)
最低对象无法选择:
var objectx = canvas.getObjects();
objectx[0].selectable = false;
最高对象无法选择:
var objectx = canvas.getObjects();
objectx[objectx.length - 1].selectable = false;
这应该可以解决问题。