Fabric gotchas

Andrea Bogazzi edited this page Dec 22, 2016 · 13 revisions
  • new fabric.Canvas('foo') wraps <canvas id="foo"> element with a <div> one, and adds another (absolutely positioned) canvas element on top of existing canvas (the one with id="foo"). This only happens for dynamic canvases (fabric.Canvas), not static ones (fabric.StaticCanvas). Also see How fabric canvas layering works.

  • When object coordinates/boundaries don't match those detected by selection, you might need to call object.setCoords(). This recalculates object's coordinates used to detect its controls.

  • When mouse-based group selection has incorrect offset on canvas, you can fix it via canvas.calcOffset(). This usually happens when canvas position in a document is changed after canvas is initialized (e.g. if there was an image before that was loaded).

  • When approaching fabric version 1.7.0 and up you should read this short description of how object caching works: Object Caching