Fabric.js: LoadFromJSON with custom class results in blank Canvas

Created on 17 Apr 2017  路  5Comments  路  Source: fabricjs/fabric.js

Version

1.7.7 and 1.7.9

Test Case

https://jsfiddle.net/knc1Leuz/18/

Steps to reproduce

  1. Just define one class and try to load from JSON. In fiddle I use the json from example.

Expected Behavior

If I use this class to draw in canvas, the result is a rect with a label in it.

Actual Behavior

After stringify and reuse the String, the result is a canvas with no elements and no errors in console (not even the classic "klass" exception)

docs

Most helpful comment

https://jsfiddle.net/knc1Leuz/19/

you need to see how another fromObject function is made and copy it.

All 5 comments

If you change the "labeledrect" from JSON to"rect" everything is "ok"

And if you change the object definition to the way that is explained here nothing of this will work. I mean, the code not even pass to calling object constructor.

https://jsfiddle.net/knc1Leuz/19/

you need to see how another fromObject function is made and copy it.

Thanks, I think that many people will be thankful with this.

This should be part of the docs!

Was this page helpful?
0 / 5 - 0 ratings