I'm using the new setControlsVisibility to remove the rotation point of an object. When exporting to JSON and loading a new canvas from the serialized JSON string, the rotation point is back.
It looks like there's no controls visibility information at all in the serialized data:
{
"objects":[
{
"type":"rect",
"originX":"left",
"originY":"top",
"left":10,
"top":10,
"width":50,
"height":50,
"fill":"rgb(0,0,0)",
"stroke":null,
"strokeWidth":1,
"strokeDashArray":null,
"strokeLineCap":"butt",
"strokeLineJoin":"miter",
"strokeMiterLimit":10,
"scaleX":1,
"scaleY":1,
"angle":0,
"flipX":false,
"flipY":false,
"opacity":1,
"shadow":null,
"visible":true,
"clipTo":null,
"backgroundColor":"",
"rx":0,
"ry":0,
"x":0,
"y":0
}
],
"background":""
}
You need to specify what are the properties you want saved when exporting. For example :
//will save properties set through setControlsVisibility
var json = canvas.toJSON(['_controlsVisibility']);
This is done to optimize the amount of data saved when serializing objects.
I'm not sure if we're supposed to add private properties through the functionality though.
Ahh, my bad.
Since this feature is quite new, I didn't find any information on it.
Thanks for pointing out a solution!
Most helpful comment
You need to specify what are the properties you want saved when exporting. For example :
This is done to optimize the amount of data saved when serializing objects.
I'm not sure if we're supposed to add private properties through the functionality though.