Upgrade to fabric 5.x
First of all the minimum node version now supported is 14. JSDOM will work with 12, and that was the reason to change, but we felt like pushing for 14 at least was the right thing to do.
In fabricJS 4.x there were some deprecated methods and functions kept for backward compatibility.
Circle startAngle and endAngle
Let’s start with the worst change: Circle.startAngle
and Circle.endAngle
are now in degree and no more in radians, fo consistency reason.
It invalidates all old design that uses circles and that were exported with default values included.
This is a wild disruptive change, all the others are fairly trivial and should not create any issue, if not with projects that used custom functionalities and overrides.
What to do
Well here is tricky, you need to attach a reviver when you import your JSON data or override the fromObject of circle to maintain compatibility.
Transform event removed
Those events are gone:
Those events were a leftover of the control logic of 3.x and before.
Do not confuse those with scaling ,rotating, moving, skewing. Those were fired at the end of a transform when some of those action occured.
See them as an extra layer detail on top of object:modified
.
As a side effect of this change, the canvas method _addEventOptions
, private and deprecated, has been removed.
The sole purpose of this method was to support this functionality.
What to do
If you need this information, you can check in the event object:modified
for the action property
Selection events properties
Events like selection:updated
and selection:created
do not have anymore the following properties:
- updated
- target
Those were compatibility properties left after the removal of the old events. Those properties referenced a fabric.Object.
What to do
In the same events you can look at selected and deselected properties that contains an array of events. The first item of those array is what was referenced on those properties.
Removal of deprecated methods
Object.calcCoords
and Object._calcDimensionsTransformMatrix
, group.realizeTransform
are gone.
Since we introduced different sets of coordiantes, aCoords and oCoords, the generic method calcCoords wasn’t really useful anymore. It wasn’t used internally anymore and was left to don’t disruput version 4.
In the future we hope to have only aCoords.
Object._calcDimensionsTransformMatrix
was handling a specific case of some transformation for the bounding boxes.
Some time ago we introduced a generic utility that can do the same, calcDimensionsMatrix
.
_calcDimensionsTransformMatrix
was deprecated and was calling calcDimensionsMatrix
with the following parameters:
Similar situation for group.realizeTransform
, unused in fabricJS, and not providing any functionality on top of the generic util it was calling
What to do
for calcCoords, just call either calcACoords or calcOCoords when you need it. for _calcDimensionsTransformMatrix and realizeTransform, call the utility as shown in the snippet.
Paths utilis removed
Since the path semplification happened in v4.x the following utils were’t usend anymore and kept for compatibility: utils.getBoundsOfArc
, utils.drawArc
, utils.fromArcToBeizers
, utils.drawDashedLine
Those utils are now removed.
What to do
drawDashedLine
, getBoundsOfArc
and drawArc
are removed, if you really need them, you need to copy them back in your code and maintain yourself.
The interesting part utils.fromArcToBeizers
is still available in fabricJS for internal use and if you need to you use it, you need to expose it on your own.