Canvas/Fabric.js .loadFromJSON() replaces entire canvas

混江龙づ霸主 提交于 2019-12-08 19:12:38

I've never tried the fromObject() method.

I'd try merging the two JSON objects first using concat, then use loadFromJson().

var finalFloorPlan = jSONObject1.concat(jSONObject2);

If you look at the code for loadFromJSON, the canvas is cleared each time.

loadFromJSON: function (json, callback, reviver) {
if (!json) {
  return;
}

// serialize if it wasn't already
var serialized = (typeof json === 'string')
  ? JSON.parse(json)
  : json;

this.clear();

var _this = this;
this._enlivenObjects(serialized.objects, function () {
  _this._setBgOverlay(serialized, callback);
}, reviver);

return this;
},

You will need to concat your two JSON objects.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!