You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { fabric } from 'fabric`` -> import * as fabric from 'fabric'`
There are some types that are not exposed yet, e.g. TMat2D, events. Before v6 stable comes out, you can expose it by add
"src/*": [
"dist/src/*"
]
to the typesVersions section. Note that it should be dist/src/* instead of src/* as mentioned here pull/8725, discussions/8715, pull/8717, otherwise it has issue (relates to event types) saying event typed in src/** can not be assigned to the same event typed in dist/src/**. Use dist/src/* will ensure all fabric objects and types are from dist therefore consistent.
import { TMat2D } from 'fabric/src/typedefs'; TMat2D is required for canvas.setViewportTransform()
for events, v5's fabric.IEvent -> import { TPointerEventInfo as IEvent } from 'fabric/src/EventTypeDefs';
canvas.getObjects() now returns BaseFabricObject (discussion/8739), you have to cast to fabric.Object if it is expected in downstream logic
setOptions() not needed anymore, just use set() for all props including custom props
setCoords() not needed anymore, just delete it, seems v6 handles that automatically now (not sure though)
new fabric.Circle({...props}) has types issue, it asks for full CircleProps which has over 50 props to fill. You can hack it by
constcircle=newfabric.Circle()// this is finecircle.set({...props})
v5 event's pointer used to be absolute coordinates, and setViewportTransform() expects absolute coordinates. In v6 event's pointer is canvas coordinates, but it returns absolutePointer which gives absolute coordinates needed for viewport transform.
In v6, canvas.remove() will trigger object:modified event if the removed object is also active. In v5 it does not trigger object:modified event.
'object:modified': (e: IEvent<MouseEvent>)=>{if(!e.e)return;// likely triggered by canvas.remove()// actually modified},
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
import { fabric } from 'fabric`` ->import * as fabric from 'fabric'`to the
typesVersionssection. Note that it should bedist/src/*instead ofsrc/*as mentioned here pull/8725, discussions/8715, pull/8717, otherwise it has issue (relates to event types) saying event typed insrc/**can not be assigned to the same event typed indist/src/**. Usedist/src/*will ensure allfabricobjects and types are fromdisttherefore consistent.import { TMat2D } from 'fabric/src/typedefs';TMat2D is required forcanvas.setViewportTransform()fabric.IEvent->import { TPointerEventInfo as IEvent } from 'fabric/src/EventTypeDefs';canvas.getObjects()now returnsBaseFabricObject(discussion/8739), you have to cast tofabric.Objectif it is expected in downstream logicsetOptions()not needed anymore, just useset()for all props including custom propssetCoords()not needed anymore, just delete it, seems v6 handles that automatically now (not sure though)new fabric.Circle({...props})has types issue, it asks for fullCirclePropswhich has over 50 props to fill. You can hack it bypointerused to be absolute coordinates, andsetViewportTransform()expects absolute coordinates. In v6 event'spointeris canvas coordinates, but it returnsabsolutePointerwhich gives absolute coordinates needed for viewport transform.canvas.remove()will triggerobject:modifiedevent if the removed object is also active. In v5 it does not triggerobject:modifiedevent.Beta Was this translation helpful? Give feedback.
All reactions