pixijs-fabric 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.ts +848 -4
- package/build/index.js +2 -2
- package/package.json +5 -2
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Application, Container, Graphics,
|
|
1
|
+
import { FederatedPointerEvent, Application, Container, Matrix, Graphics, Rectangle } from 'pixi.js';
|
|
2
2
|
|
|
3
3
|
interface BorderProps {
|
|
4
4
|
/**
|
|
@@ -539,10 +539,24 @@ declare class InteractiveFabricObject<Props extends TFabricObjectProps = Partial
|
|
|
539
539
|
static getDefaults(): Record<string, any>;
|
|
540
540
|
constructor(options?: Props);
|
|
541
541
|
strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void;
|
|
542
|
+
onDeselect(_options?: {
|
|
543
|
+
e?: TPointerEvent;
|
|
544
|
+
object?: InteractiveFabricObject;
|
|
545
|
+
}): boolean;
|
|
546
|
+
onSelect(_options?: {
|
|
547
|
+
e?: TPointerEvent;
|
|
548
|
+
}): boolean;
|
|
542
549
|
setControlVisible(controlKey: string, visible: boolean): void;
|
|
543
550
|
setControlsVisibility(options?: Record<string, boolean>): void;
|
|
551
|
+
shouldStartDragging(_e: FederatedPointerEvent): boolean;
|
|
552
|
+
onDragStart(_e: DragEvent): boolean;
|
|
544
553
|
}
|
|
545
554
|
|
|
555
|
+
declare module 'pixi.js' {
|
|
556
|
+
interface Container {
|
|
557
|
+
fabricContent: FabricObject;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
546
560
|
declare class FabricObject<Props extends TFabricObjectProps = Partial<FabricObjectProps>, SProps extends SerializedObjectProps = SerializedObjectProps, EventSpec extends ObjectEvents = ObjectEvents> extends InteractiveFabricObject<Props, SProps, EventSpec> {
|
|
547
561
|
}
|
|
548
562
|
|
|
@@ -799,6 +813,7 @@ declare class StaticCanvas extends StaticCanvas_base implements StaticCanvasOpti
|
|
|
799
813
|
height: number;
|
|
800
814
|
}): void;
|
|
801
815
|
getZoom(): number;
|
|
816
|
+
getViewportTransform(): Matrix;
|
|
802
817
|
setViewportTransform(vpt: TMat2D): void;
|
|
803
818
|
zoomToPoint(point: Point, value: number): void;
|
|
804
819
|
setZoom(value: number): void;
|
|
@@ -816,6 +831,10 @@ declare class StaticCanvas extends StaticCanvas_base implements StaticCanvasOpti
|
|
|
816
831
|
insertAt(index: number, ...objects: FabricObject[]): number;
|
|
817
832
|
remove(...objects: FabricObject[]): FabricObject<Partial<FabricObjectProps>, SerializedObjectProps, ObjectEvents>[];
|
|
818
833
|
get lowerCanvasEl(): HTMLCanvasElement;
|
|
834
|
+
/**
|
|
835
|
+
* @deprecated
|
|
836
|
+
* 没有upperCanvasEl,返回的依然是lowerCanvasEl
|
|
837
|
+
*/
|
|
819
838
|
get upperCanvasEl(): HTMLCanvasElement;
|
|
820
839
|
getContext(): CanvasRenderingContext2D;
|
|
821
840
|
getElement(): HTMLCanvasElement;
|
|
@@ -847,6 +866,710 @@ declare class StaticCanvas extends StaticCanvas_base implements StaticCanvasOpti
|
|
|
847
866
|
toBlob(options?: TDataUrlOptions): Promise<Blob | null>;
|
|
848
867
|
toCanvasElement(multiplier?: number): HTMLCanvasElement;
|
|
849
868
|
toString(): string;
|
|
869
|
+
destroy(): void;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
interface CanvasTransformOptions {
|
|
873
|
+
/**
|
|
874
|
+
* When true, objects can be transformed by one side (unproportionately)
|
|
875
|
+
* when dragged on the corners that normally would not do that.
|
|
876
|
+
* @type Boolean
|
|
877
|
+
* @since fabric 4.0 // changed name and default value
|
|
878
|
+
*/
|
|
879
|
+
uniformScaling: boolean;
|
|
880
|
+
/**
|
|
881
|
+
* Indicates which key switches uniform scaling.
|
|
882
|
+
* values: 'altKey', 'shiftKey', 'ctrlKey'.
|
|
883
|
+
* If `null` or 'none' or any other string that is not a modifier key
|
|
884
|
+
* feature is disabled.
|
|
885
|
+
* totally wrong named. this sounds like `uniform scaling`
|
|
886
|
+
* if Canvas.uniformScaling is true, pressing this will set it to false
|
|
887
|
+
* and viceversa.
|
|
888
|
+
* @since 1.6.2
|
|
889
|
+
* @type ModifierKey
|
|
890
|
+
*/
|
|
891
|
+
uniScaleKey: TOptionalModifierKey;
|
|
892
|
+
/**
|
|
893
|
+
* When true, objects use center point as the origin of scale transformation.
|
|
894
|
+
* <b>Backwards incompatibility note:</b> This property replaces "centerTransform" (Boolean).
|
|
895
|
+
* @since 1.3.4
|
|
896
|
+
* @type Boolean
|
|
897
|
+
*/
|
|
898
|
+
centeredScaling: boolean;
|
|
899
|
+
/**
|
|
900
|
+
* When true, objects use center point as the origin of rotate transformation.
|
|
901
|
+
* <b>Backwards incompatibility note:</b> This property replaces "centerTransform" (Boolean).
|
|
902
|
+
* @since 1.3.4
|
|
903
|
+
* @type Boolean
|
|
904
|
+
*/
|
|
905
|
+
centeredRotation: boolean;
|
|
906
|
+
/**
|
|
907
|
+
* Indicates which key enable centered Transform
|
|
908
|
+
* values: 'altKey', 'shiftKey', 'ctrlKey'.
|
|
909
|
+
* If `null` or 'none' or any other string that is not a modifier key
|
|
910
|
+
* feature is disabled feature disabled.
|
|
911
|
+
* @since 1.6.2
|
|
912
|
+
* @type ModifierKey
|
|
913
|
+
*/
|
|
914
|
+
centeredKey: TOptionalModifierKey;
|
|
915
|
+
/**
|
|
916
|
+
* Indicates which key enable alternate action on corner
|
|
917
|
+
* values: 'altKey', 'shiftKey', 'ctrlKey'.
|
|
918
|
+
* If `null` or 'none' or any other string that is not a modifier key
|
|
919
|
+
* feature is disabled feature disabled.
|
|
920
|
+
* @since 1.6.2
|
|
921
|
+
* @type ModifierKey
|
|
922
|
+
*/
|
|
923
|
+
altActionKey: TOptionalModifierKey;
|
|
924
|
+
}
|
|
925
|
+
interface CanvasSelectionOptions {
|
|
926
|
+
/**
|
|
927
|
+
* Indicates whether group selection should be enabled
|
|
928
|
+
* @type Boolean
|
|
929
|
+
*/
|
|
930
|
+
selection: boolean;
|
|
931
|
+
/**
|
|
932
|
+
* Indicates which key or keys enable multiple click selection
|
|
933
|
+
* Pass value as a string or array of strings
|
|
934
|
+
* values: 'altKey', 'shiftKey', 'ctrlKey'.
|
|
935
|
+
* If `null` or empty or containing any other string that is not a modifier key
|
|
936
|
+
* feature is disabled.
|
|
937
|
+
* @since 1.6.2
|
|
938
|
+
* @type ModifierKey|ModifierKey[]
|
|
939
|
+
*/
|
|
940
|
+
selectionKey: TOptionalModifierKey | ModifierKey[];
|
|
941
|
+
/**
|
|
942
|
+
* Indicates which key enable alternative selection
|
|
943
|
+
* in case of a target overlapping with active object and we don't want to loose the
|
|
944
|
+
* active selection, we can press this modifier key and continue selecting the current
|
|
945
|
+
* selected object also when is covered by another or many valid targets for selection.
|
|
946
|
+
* values: 'altKey', 'shiftKey', 'ctrlKey'.
|
|
947
|
+
* For a series of reason that come from the general expectations on how
|
|
948
|
+
* things should work, this feature works only for preserveObjectStacking true.
|
|
949
|
+
* If `null` or 'none' or any other string that is not a modifier key
|
|
950
|
+
* feature is disabled.
|
|
951
|
+
* @since 1.6.5
|
|
952
|
+
* @type null|ModifierKey
|
|
953
|
+
*/
|
|
954
|
+
altSelectionKey: TOptionalModifierKey;
|
|
955
|
+
/**
|
|
956
|
+
* Color of selection
|
|
957
|
+
* @type String
|
|
958
|
+
*/
|
|
959
|
+
selectionColor: string;
|
|
960
|
+
/**
|
|
961
|
+
* Default dash array pattern
|
|
962
|
+
* If not empty the selection border is dashed
|
|
963
|
+
* @type Array
|
|
964
|
+
*/
|
|
965
|
+
selectionDashArray: number[];
|
|
966
|
+
/**
|
|
967
|
+
* Color of the border of selection (usually slightly darker than color of selection itself)
|
|
968
|
+
* @type String
|
|
969
|
+
*/
|
|
970
|
+
selectionBorderColor: string;
|
|
971
|
+
/**
|
|
972
|
+
* Width of a line used in object/group selection
|
|
973
|
+
* @type Number
|
|
974
|
+
*/
|
|
975
|
+
selectionLineWidth: number;
|
|
976
|
+
/**
|
|
977
|
+
* Select only shapes that are fully contained in the dragged selection rectangle.
|
|
978
|
+
* @type Boolean
|
|
979
|
+
*/
|
|
980
|
+
selectionFullyContained: boolean;
|
|
981
|
+
}
|
|
982
|
+
interface CanvasCursorOptions {
|
|
983
|
+
/**
|
|
984
|
+
* Default cursor value used when hovering over an object on canvas
|
|
985
|
+
* @type CSSStyleDeclaration['cursor']
|
|
986
|
+
* @default move
|
|
987
|
+
*/
|
|
988
|
+
hoverCursor: CSSStyleDeclaration['cursor'];
|
|
989
|
+
/**
|
|
990
|
+
* Default cursor value used when moving an object on canvas
|
|
991
|
+
* @type CSSStyleDeclaration['cursor']
|
|
992
|
+
* @default move
|
|
993
|
+
*/
|
|
994
|
+
moveCursor: CSSStyleDeclaration['cursor'];
|
|
995
|
+
/**
|
|
996
|
+
* Default cursor value used for the entire canvas
|
|
997
|
+
* @type String
|
|
998
|
+
* @default default
|
|
999
|
+
*/
|
|
1000
|
+
defaultCursor: CSSStyleDeclaration['cursor'];
|
|
1001
|
+
/**
|
|
1002
|
+
* Cursor value used during free drawing
|
|
1003
|
+
* @type String
|
|
1004
|
+
* @default crosshair
|
|
1005
|
+
*/
|
|
1006
|
+
freeDrawingCursor: CSSStyleDeclaration['cursor'];
|
|
1007
|
+
/**
|
|
1008
|
+
* Cursor value used for disabled elements ( corners with disabled action )
|
|
1009
|
+
* @type String
|
|
1010
|
+
* @since 2.0.0
|
|
1011
|
+
* @default not-allowed
|
|
1012
|
+
*/
|
|
1013
|
+
notAllowedCursor: CSSStyleDeclaration['cursor'];
|
|
1014
|
+
}
|
|
1015
|
+
interface TargetFindOptions {
|
|
1016
|
+
/**
|
|
1017
|
+
* When true, target detection is skipped. Target detection will return always undefined.
|
|
1018
|
+
* click selection won't work anymore, events will fire with no targets.
|
|
1019
|
+
* if something is selected before setting it to true, it will be deselected at the first click.
|
|
1020
|
+
* area selection will still work. check the `selection` property too.
|
|
1021
|
+
* if you deactivate both, you should look into staticCanvas.
|
|
1022
|
+
* @type Boolean
|
|
1023
|
+
*/
|
|
1024
|
+
skipTargetFind: boolean;
|
|
1025
|
+
}
|
|
1026
|
+
interface CanvasEventsOptions {
|
|
1027
|
+
/**
|
|
1028
|
+
* Indicates if the right click on canvas can output the context menu or not
|
|
1029
|
+
* The default value changed from false to true in Fabric 7.0
|
|
1030
|
+
* @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/
|
|
1031
|
+
* @deprecated since 7.0, Will be removed in Fabric 8.0
|
|
1032
|
+
* @type Boolean
|
|
1033
|
+
* @since 1.6.5
|
|
1034
|
+
*/
|
|
1035
|
+
stopContextMenu: boolean;
|
|
1036
|
+
/**
|
|
1037
|
+
* Indicates if the canvas can fire right click events
|
|
1038
|
+
* The default value changed from false to true in Fabric 7.0
|
|
1039
|
+
* @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/
|
|
1040
|
+
* @deprecated since 7.0, Will be removed in Fabric 8.0
|
|
1041
|
+
* @type Boolean
|
|
1042
|
+
* @since 1.6.5
|
|
1043
|
+
*/
|
|
1044
|
+
fireRightClick: boolean;
|
|
1045
|
+
/**
|
|
1046
|
+
* Indicates if the canvas can fire middle click events
|
|
1047
|
+
* The default value changed from false to true in Fabric 7.0
|
|
1048
|
+
* @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/
|
|
1049
|
+
* @deprecated since 7.0, Will be removed in Fabric 8.0
|
|
1050
|
+
* @type Boolean
|
|
1051
|
+
* @since 1.7.8
|
|
1052
|
+
*/
|
|
1053
|
+
fireMiddleClick: boolean;
|
|
1054
|
+
/**
|
|
1055
|
+
* When the option is enabled, PointerEvent is used instead of TPointerEvent.
|
|
1056
|
+
* @type Boolean
|
|
1057
|
+
*/
|
|
1058
|
+
enablePointerEvents: boolean;
|
|
1059
|
+
}
|
|
1060
|
+
interface CanvasOptions extends StaticCanvasOptions, CanvasTransformOptions, CanvasSelectionOptions, CanvasCursorOptions, TargetFindOptions, CanvasEventsOptions {
|
|
1061
|
+
/**
|
|
1062
|
+
* Default element class that's given to wrapper (div) element of canvas
|
|
1063
|
+
* @type String
|
|
1064
|
+
* @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly
|
|
1065
|
+
*/
|
|
1066
|
+
containerClass: string;
|
|
1067
|
+
/**
|
|
1068
|
+
* Indicates whether objects should remain in current stack position when selected.
|
|
1069
|
+
* When false objects are brought to top and rendered as part of the selection group
|
|
1070
|
+
* @type Boolean
|
|
1071
|
+
* @default true
|
|
1072
|
+
*/
|
|
1073
|
+
preserveObjectStacking: boolean;
|
|
1074
|
+
}
|
|
1075
|
+
type TCanvasOptions = TOptions<CanvasOptions>;
|
|
1076
|
+
|
|
1077
|
+
type TargetsInfoWithContainer = {
|
|
1078
|
+
target?: FabricObject;
|
|
1079
|
+
subTargets: FabricObject[];
|
|
1080
|
+
container?: FabricObject;
|
|
1081
|
+
};
|
|
1082
|
+
type FullTargetsInfoWithContainer = TargetsInfoWithContainer & {
|
|
1083
|
+
currentTarget?: FabricObject;
|
|
1084
|
+
currentContainer?: FabricObject;
|
|
1085
|
+
currentSubTargets: FabricObject[];
|
|
1086
|
+
};
|
|
1087
|
+
declare class SelectableCanvas extends StaticCanvas implements Omit<CanvasOptions, 'enablePointerEvents'> {
|
|
1088
|
+
_objects: FabricObject[];
|
|
1089
|
+
uniformScaling: boolean;
|
|
1090
|
+
uniScaleKey: TOptionalModifierKey;
|
|
1091
|
+
centeredScaling: boolean;
|
|
1092
|
+
centeredRotation: boolean;
|
|
1093
|
+
centeredKey: TOptionalModifierKey;
|
|
1094
|
+
altActionKey: TOptionalModifierKey;
|
|
1095
|
+
selection: boolean;
|
|
1096
|
+
selectionKey: TOptionalModifierKey | ModifierKey[];
|
|
1097
|
+
altSelectionKey: TOptionalModifierKey;
|
|
1098
|
+
selectionColor: string;
|
|
1099
|
+
selectionDashArray: number[];
|
|
1100
|
+
selectionBorderColor: string;
|
|
1101
|
+
selectionLineWidth: number;
|
|
1102
|
+
selectionFullyContained: boolean;
|
|
1103
|
+
hoverCursor: CSSStyleDeclaration['cursor'];
|
|
1104
|
+
moveCursor: CSSStyleDeclaration['cursor'];
|
|
1105
|
+
defaultCursor: CSSStyleDeclaration['cursor'];
|
|
1106
|
+
freeDrawingCursor: CSSStyleDeclaration['cursor'];
|
|
1107
|
+
notAllowedCursor: CSSStyleDeclaration['cursor'];
|
|
1108
|
+
containerClass: string;
|
|
1109
|
+
skipTargetFind: boolean;
|
|
1110
|
+
preserveObjectStacking: boolean;
|
|
1111
|
+
stopContextMenu: boolean;
|
|
1112
|
+
fireRightClick: boolean;
|
|
1113
|
+
fireMiddleClick: boolean;
|
|
1114
|
+
/**
|
|
1115
|
+
* Keep track of the hovered target in the previous event
|
|
1116
|
+
* @type FabricObject | null
|
|
1117
|
+
* @private
|
|
1118
|
+
*/
|
|
1119
|
+
_hoveredTarget?: FabricObject;
|
|
1120
|
+
/**
|
|
1121
|
+
* hold the list of nested targets hovered in the previous events
|
|
1122
|
+
* @type FabricObject[]
|
|
1123
|
+
* @private
|
|
1124
|
+
*/
|
|
1125
|
+
_hoveredTargets: FabricObject[];
|
|
1126
|
+
/**
|
|
1127
|
+
* hold the list of objects to render
|
|
1128
|
+
* @type FabricObject[]
|
|
1129
|
+
* @private
|
|
1130
|
+
*/
|
|
1131
|
+
_objectsToRender?: FabricObject[];
|
|
1132
|
+
/**
|
|
1133
|
+
* hold a reference to a data structure that contains information
|
|
1134
|
+
* on the current on going transform
|
|
1135
|
+
* @type
|
|
1136
|
+
* @private
|
|
1137
|
+
*/
|
|
1138
|
+
_currentTransform: Transform | null;
|
|
1139
|
+
/**
|
|
1140
|
+
* hold a reference to a data structure used to track the selection
|
|
1141
|
+
* box on canvas drag
|
|
1142
|
+
* on the current on going transform
|
|
1143
|
+
* x, y, deltaX and deltaY are in scene plane
|
|
1144
|
+
* @type
|
|
1145
|
+
* @private
|
|
1146
|
+
*/
|
|
1147
|
+
protected _groupSelector: {
|
|
1148
|
+
x: number;
|
|
1149
|
+
y: number;
|
|
1150
|
+
deltaX: number;
|
|
1151
|
+
deltaY: number;
|
|
1152
|
+
} | null;
|
|
1153
|
+
/**
|
|
1154
|
+
* internal flag used to understand if the context top requires a cleanup
|
|
1155
|
+
* in case this is true, the contextTop will be cleared at the next render
|
|
1156
|
+
* @type boolean
|
|
1157
|
+
* @private
|
|
1158
|
+
*/
|
|
1159
|
+
contextTopDirty: boolean;
|
|
1160
|
+
/**
|
|
1161
|
+
* During a mouse event we may need the pointer multiple times in multiple functions.
|
|
1162
|
+
* _scenePoint holds a reference to the pointer in fabricCanvas/design coordinates that is valid for the event
|
|
1163
|
+
* lifespan. Every fabricJS mouse event create and delete the cache every time
|
|
1164
|
+
* We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates
|
|
1165
|
+
* @type {Point}
|
|
1166
|
+
*/
|
|
1167
|
+
protected _scenePoint?: Point;
|
|
1168
|
+
/**
|
|
1169
|
+
* During a mouse event we may need the pointer multiple times in multiple functions.
|
|
1170
|
+
* _viewportPoint holds a reference to the pointer in html coordinates that is valid for the event
|
|
1171
|
+
* lifespan. Every fabricJS mouse event create and delete the cache every time
|
|
1172
|
+
* We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates
|
|
1173
|
+
* @type {Point}
|
|
1174
|
+
*/
|
|
1175
|
+
protected _viewportPoint?: Point;
|
|
1176
|
+
/**
|
|
1177
|
+
* Holds the informations we cache during an event lifespan
|
|
1178
|
+
* This data is needed many times during an event and we want to avoid to recalculate it
|
|
1179
|
+
* multuple times.
|
|
1180
|
+
*/
|
|
1181
|
+
protected _targetInfo: FullTargetsInfoWithContainer | undefined;
|
|
1182
|
+
static ownDefaults: TOptions<CanvasOptions>;
|
|
1183
|
+
static getDefaults(): Record<string, any>;
|
|
1184
|
+
/**
|
|
1185
|
+
* @deprecated
|
|
1186
|
+
* 没有upper canvas,只有一个canvas
|
|
1187
|
+
*/
|
|
1188
|
+
get upperCanvasEl(): HTMLCanvasElement;
|
|
1189
|
+
/**
|
|
1190
|
+
* @deprecated
|
|
1191
|
+
* 没有upper canvas,只有一个canvas
|
|
1192
|
+
*/
|
|
1193
|
+
get contextTop(): CanvasRenderingContext2D;
|
|
1194
|
+
/**
|
|
1195
|
+
* @deprecated
|
|
1196
|
+
* 没有container,只有一个裸canvas,所以直接返回这个canvas的父元素
|
|
1197
|
+
*/
|
|
1198
|
+
get wrapperEl(): ParentNode | null;
|
|
1199
|
+
_activeObject?: FabricObject;
|
|
1200
|
+
/**
|
|
1201
|
+
* @private
|
|
1202
|
+
* @param {FabricObject} obj Object that was added
|
|
1203
|
+
*/
|
|
1204
|
+
_onObjectAdded(obj: FabricObject): void;
|
|
1205
|
+
/**
|
|
1206
|
+
* @private
|
|
1207
|
+
* @param {FabricObject} obj Object that was removed
|
|
1208
|
+
*/
|
|
1209
|
+
_onObjectRemoved(obj: FabricObject): void;
|
|
1210
|
+
_onStackOrderChanged(): void;
|
|
1211
|
+
/**
|
|
1212
|
+
* Divides objects in two groups, one to render immediately
|
|
1213
|
+
* and one to render as activeGroup.
|
|
1214
|
+
* @return {Array} objects to render immediately and pushes the other in the activeGroup.
|
|
1215
|
+
*/
|
|
1216
|
+
_chooseObjectsToRender(): FabricObject[];
|
|
1217
|
+
/**
|
|
1218
|
+
* Renders both the top canvas and the secondary container canvas.
|
|
1219
|
+
*/
|
|
1220
|
+
renderAll(): void;
|
|
1221
|
+
/**
|
|
1222
|
+
* text selection is rendered by the active text instance during the rendering cycle
|
|
1223
|
+
*/
|
|
1224
|
+
renderTopLayer(): void;
|
|
1225
|
+
/**
|
|
1226
|
+
* Method to render only the top canvas.
|
|
1227
|
+
* Also used to render the group selection box.
|
|
1228
|
+
* Does not render text selection.
|
|
1229
|
+
*/
|
|
1230
|
+
renderTop(): void;
|
|
1231
|
+
/**
|
|
1232
|
+
* takes an event and determines if selection key has been pressed
|
|
1233
|
+
* @private
|
|
1234
|
+
* @param {TPointerEvent} e Event object
|
|
1235
|
+
*/
|
|
1236
|
+
_isSelectionKeyPressed(e: TPointerEvent): boolean;
|
|
1237
|
+
/**
|
|
1238
|
+
* @private
|
|
1239
|
+
* @param {TPointerEvent} e Event object
|
|
1240
|
+
* @param {FabricObject} target
|
|
1241
|
+
*/
|
|
1242
|
+
_shouldClearSelection(e: TPointerEvent, target?: FabricObject): target is undefined;
|
|
1243
|
+
/**
|
|
1244
|
+
* Set the cursor type of the canvas element
|
|
1245
|
+
* @param {String} value Cursor type of the canvas element.
|
|
1246
|
+
* @see http://www.w3.org/TR/css3-ui/#cursor
|
|
1247
|
+
*/
|
|
1248
|
+
setCursor(value: CSSStyleDeclaration['cursor']): void;
|
|
1249
|
+
/**
|
|
1250
|
+
* @private
|
|
1251
|
+
* @param {CanvasRenderingContext2D} ctx to draw the selection on
|
|
1252
|
+
*/
|
|
1253
|
+
protected _drawSelection(): void;
|
|
1254
|
+
/**
|
|
1255
|
+
* @deprecated
|
|
1256
|
+
* 没有upper canvas,只有一个canvas
|
|
1257
|
+
* Returns context of top canvas where interactions are drawn
|
|
1258
|
+
* @returns {CanvasRenderingContext2D}
|
|
1259
|
+
*/
|
|
1260
|
+
getTopContext(): CanvasRenderingContext2D;
|
|
1261
|
+
/**
|
|
1262
|
+
* @deprecated
|
|
1263
|
+
* 没有upper canvas,只有一个canvas
|
|
1264
|
+
* Returns context of canvas where object selection is drawn
|
|
1265
|
+
* @alias
|
|
1266
|
+
* @return {CanvasRenderingContext2D}
|
|
1267
|
+
*/
|
|
1268
|
+
getSelectionContext(): CanvasRenderingContext2D;
|
|
1269
|
+
/**
|
|
1270
|
+
* @deprecated
|
|
1271
|
+
* 没有upper canvas,只有一个canvas
|
|
1272
|
+
* Returns <canvas> element on which object selection is drawn
|
|
1273
|
+
* @return {HTMLCanvasElement}
|
|
1274
|
+
*/
|
|
1275
|
+
getSelectionElement(): HTMLCanvasElement;
|
|
1276
|
+
/**
|
|
1277
|
+
* Returns currently active object
|
|
1278
|
+
* @return {FabricObject | null} active object
|
|
1279
|
+
*/
|
|
1280
|
+
getActiveObject(): FabricObject | undefined;
|
|
1281
|
+
/**
|
|
1282
|
+
* Returns an array with the current selected objects
|
|
1283
|
+
* @return {FabricObject[]} active objects array
|
|
1284
|
+
*/
|
|
1285
|
+
getActiveObjects(): FabricObject[];
|
|
1286
|
+
/**
|
|
1287
|
+
* @private
|
|
1288
|
+
* Compares the old activeObject with the current one and fires correct events
|
|
1289
|
+
* @param {FabricObject[]} oldObjects old activeObject
|
|
1290
|
+
* @param {TPointerEvent} e mouse event triggering the selection events
|
|
1291
|
+
*/
|
|
1292
|
+
_fireSelectionEvents(oldObjects: FabricObject[], e?: TPointerEvent): void;
|
|
1293
|
+
/**
|
|
1294
|
+
* Sets given object as the only active object on canvas
|
|
1295
|
+
* @param {FabricObject} object Object to set as an active one
|
|
1296
|
+
* @param {TPointerEvent} [e] Event (passed along when firing "object:selected")
|
|
1297
|
+
* @return {Boolean} true if the object has been selected
|
|
1298
|
+
*/
|
|
1299
|
+
setActiveObject(object: FabricObject, e?: TPointerEvent): boolean;
|
|
1300
|
+
/**
|
|
1301
|
+
* This is supposed to be equivalent to setActiveObject but without firing
|
|
1302
|
+
* any event. There is commitment to have this stay this way.
|
|
1303
|
+
* This is the functional part of setActiveObject.
|
|
1304
|
+
* @param {Object} object to set as active
|
|
1305
|
+
* @param {Event} [e] Event (passed along when firing "object:selected")
|
|
1306
|
+
* @return {Boolean} true if the object has been selected
|
|
1307
|
+
*/
|
|
1308
|
+
_setActiveObject(object: FabricObject, e?: TPointerEvent): boolean;
|
|
1309
|
+
/**
|
|
1310
|
+
* This is supposed to be equivalent to discardActiveObject but without firing
|
|
1311
|
+
* any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.
|
|
1312
|
+
* This is the functional part of discardActiveObject.
|
|
1313
|
+
* @param {Event} [e] Event (passed along when firing "object:deselected")
|
|
1314
|
+
* @param {Object} object the next object to set as active, reason why we are discarding this
|
|
1315
|
+
* @return {Boolean} true if the active object has been discarded
|
|
1316
|
+
*/
|
|
1317
|
+
_discardActiveObject(e?: TPointerEvent, object?: FabricObject): this is {
|
|
1318
|
+
_activeObject: undefined;
|
|
1319
|
+
};
|
|
1320
|
+
/**
|
|
1321
|
+
* Discards currently active object and fire events. If the function is called by fabric
|
|
1322
|
+
* as a consequence of a mouse event, the event is passed as a parameter and
|
|
1323
|
+
* sent to the fire function for the custom events. When used as a method the
|
|
1324
|
+
* e param does not have any application.
|
|
1325
|
+
* @param {event} e
|
|
1326
|
+
* @return {Boolean} true if the active object has been discarded
|
|
1327
|
+
*/
|
|
1328
|
+
discardActiveObject(e?: TPointerEvent): this is {
|
|
1329
|
+
_activeObject: undefined;
|
|
1330
|
+
};
|
|
1331
|
+
/**
|
|
1332
|
+
* End the current transform.
|
|
1333
|
+
* You don't usually need to call this method unless you are interrupting a user initiated transform
|
|
1334
|
+
* because of some other event ( a press of key combination, or something that block the user UX )
|
|
1335
|
+
* @param {Event} [e] send the mouse event that generate the finalize down, so it can be used in the event
|
|
1336
|
+
*/
|
|
1337
|
+
endCurrentTransform(e?: TPointerEvent): void;
|
|
1338
|
+
/**
|
|
1339
|
+
* @private
|
|
1340
|
+
* @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event
|
|
1341
|
+
*/
|
|
1342
|
+
_finalizeCurrentTransform(e?: TPointerEvent): void;
|
|
1343
|
+
/**
|
|
1344
|
+
* Sets viewport transformation of this canvas instance
|
|
1345
|
+
* @param {Array} vpt a Canvas 2D API transform matrix
|
|
1346
|
+
*/
|
|
1347
|
+
setViewportTransform(vpt: TMat2D): void;
|
|
1348
|
+
/**
|
|
1349
|
+
* Clears all contexts (background, main, top) of an instance
|
|
1350
|
+
*/
|
|
1351
|
+
clear(): void;
|
|
1352
|
+
/**
|
|
1353
|
+
* Draws objects' controls (borders/controls)
|
|
1354
|
+
* @param {CanvasRenderingContext2D} ctx Context to render controls on
|
|
1355
|
+
*/
|
|
1356
|
+
drawControls(ctx: CanvasRenderingContext2D): void;
|
|
1357
|
+
/**
|
|
1358
|
+
* @private
|
|
1359
|
+
*/
|
|
1360
|
+
protected _toObject(instance: FabricObject, methodName: 'toObject' | 'toDatalessObject', propertiesToInclude: string[]): Record<string, any>;
|
|
1361
|
+
/**
|
|
1362
|
+
* Realizes an object's group transformation on it
|
|
1363
|
+
* @private
|
|
1364
|
+
* @param {FabricObject} [instance] the object to transform (gets mutated)
|
|
1365
|
+
* @returns the original values of instance which were changed
|
|
1366
|
+
*/
|
|
1367
|
+
private _realizeGroupTransformOnObject;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
declare class Canvas extends SelectableCanvas implements CanvasOptions {
|
|
1371
|
+
/**
|
|
1372
|
+
* Contains the id of the touch event that owns the fabric transform
|
|
1373
|
+
* @type Number
|
|
1374
|
+
* @private
|
|
1375
|
+
*/
|
|
1376
|
+
mainTouchId?: number;
|
|
1377
|
+
enablePointerEvents: boolean;
|
|
1378
|
+
/**
|
|
1379
|
+
* Holds a reference to a setTimeout timer for event synchronization
|
|
1380
|
+
* @type number
|
|
1381
|
+
* @private
|
|
1382
|
+
*/
|
|
1383
|
+
private _willAddMouseDown;
|
|
1384
|
+
/**
|
|
1385
|
+
* Holds a reference to an object on the canvas that is receiving the drag over event.
|
|
1386
|
+
* @type FabricObject
|
|
1387
|
+
* @private
|
|
1388
|
+
*/
|
|
1389
|
+
private _draggedoverTarget?;
|
|
1390
|
+
/**
|
|
1391
|
+
* Holds a reference to an object on the canvas from where the drag operation started
|
|
1392
|
+
* @type FabricObject
|
|
1393
|
+
* @private
|
|
1394
|
+
*/
|
|
1395
|
+
private _dragSource?;
|
|
1396
|
+
private dragInitInfo;
|
|
1397
|
+
private selectionGrap;
|
|
1398
|
+
private mouseDown;
|
|
1399
|
+
/**
|
|
1400
|
+
* Holds a reference to an object on the canvas that is the current drop target
|
|
1401
|
+
* May differ from {@link _draggedoverTarget}
|
|
1402
|
+
* @todo inspect whether {@link _draggedoverTarget} and {@link _dropTarget} should be merged somehow
|
|
1403
|
+
* @type FabricObject
|
|
1404
|
+
* @private
|
|
1405
|
+
*/
|
|
1406
|
+
private _dropTarget;
|
|
1407
|
+
/**
|
|
1408
|
+
* a boolean that keeps track of the click state during a cycle of mouse down/up.
|
|
1409
|
+
* If a mouse move occurs it becomes false.
|
|
1410
|
+
* Is true by default, turns false on mouse move.
|
|
1411
|
+
* Used to determine if a mouseUp is a click
|
|
1412
|
+
*/
|
|
1413
|
+
private _isClick;
|
|
1414
|
+
/**
|
|
1415
|
+
* 处理点击相关的逻辑
|
|
1416
|
+
*/
|
|
1417
|
+
private clickInfo;
|
|
1418
|
+
private hasFiredDragStart;
|
|
1419
|
+
constructor(el?: string | HTMLCanvasElement, options?: TCanvasOptions);
|
|
1420
|
+
private addGraps;
|
|
1421
|
+
private bindEvents;
|
|
1422
|
+
protected _drawSelection(): void;
|
|
1423
|
+
/**
|
|
1424
|
+
* @private
|
|
1425
|
+
* @param {Event} [e] Event object fired on wheel event
|
|
1426
|
+
*/
|
|
1427
|
+
private _onMouseWheel;
|
|
1428
|
+
/**
|
|
1429
|
+
* @private
|
|
1430
|
+
* @param {Event} e Event object fired on mousedown
|
|
1431
|
+
*/
|
|
1432
|
+
private _onMouseOut;
|
|
1433
|
+
/**
|
|
1434
|
+
* @private
|
|
1435
|
+
* @param {Event} e Event object fired on mousedown
|
|
1436
|
+
*/
|
|
1437
|
+
private _onContextMenu;
|
|
1438
|
+
/**
|
|
1439
|
+
* Return a the id of an event.
|
|
1440
|
+
* returns either the pointerId or the identifier or 0 for the mouse event
|
|
1441
|
+
* @private
|
|
1442
|
+
* @param {Event} evt Event object
|
|
1443
|
+
*/
|
|
1444
|
+
getPointerId(evt: TouchEvent | PointerEvent): number;
|
|
1445
|
+
/**
|
|
1446
|
+
* Determines if an event has the id of the event that is considered main
|
|
1447
|
+
* @private
|
|
1448
|
+
* @param {evt} event Event object
|
|
1449
|
+
*/
|
|
1450
|
+
_isMainEvent(evt: TPointerEvent): boolean;
|
|
1451
|
+
private handleDragMove;
|
|
1452
|
+
/**
|
|
1453
|
+
* @private
|
|
1454
|
+
* @param {Event} e Event object fired on mousemove
|
|
1455
|
+
*/
|
|
1456
|
+
private _onMouseMove;
|
|
1457
|
+
/**
|
|
1458
|
+
* @private
|
|
1459
|
+
*/
|
|
1460
|
+
_onResize(): void;
|
|
1461
|
+
/**
|
|
1462
|
+
* Decides whether the canvas should be redrawn in mouseup and mousedown events.
|
|
1463
|
+
* @private
|
|
1464
|
+
* @param {Object} target
|
|
1465
|
+
*/
|
|
1466
|
+
_shouldRender(target: FabricObject | undefined): boolean | undefined;
|
|
1467
|
+
private handleTripleClick;
|
|
1468
|
+
private handleDbClick;
|
|
1469
|
+
private handleClick;
|
|
1470
|
+
private handlePotentialClick;
|
|
1471
|
+
private handleDragStart;
|
|
1472
|
+
/**
|
|
1473
|
+
* Method that defines the actions when mouse is clicked on canvas.
|
|
1474
|
+
* The method inits the currentTransform parameters and renders all the
|
|
1475
|
+
* canvas so the current image can be placed on the top canvas and the rest
|
|
1476
|
+
* in on the container one.
|
|
1477
|
+
* @private
|
|
1478
|
+
* @param {Event} e Event object fired on mousedown
|
|
1479
|
+
*/
|
|
1480
|
+
private _onMouseDown;
|
|
1481
|
+
private handleDragEnd;
|
|
1482
|
+
private _onMouseUpOutside;
|
|
1483
|
+
/**
|
|
1484
|
+
* Method that defines the actions when mouse is released on canvas.
|
|
1485
|
+
* The method resets the currentTransform parameters, store the image corner
|
|
1486
|
+
* position in the image object and render the canvas on top.
|
|
1487
|
+
* @private
|
|
1488
|
+
* @param {Event} e Event object fired on mouseup
|
|
1489
|
+
*/
|
|
1490
|
+
private _onMouseUp;
|
|
1491
|
+
_basicEventHandler<T extends keyof (CanvasEvents | ObjectEvents)>(eventType: T, options: (CanvasEvents & ObjectEvents)[T]): (CanvasEvents & ObjectEvents)[T];
|
|
1492
|
+
/**
|
|
1493
|
+
* @private
|
|
1494
|
+
* Handle event firing for target and subtargets
|
|
1495
|
+
* @param {TPointerEvent} e event from mouse
|
|
1496
|
+
* @param {TPointerEventNames} eventType
|
|
1497
|
+
*/
|
|
1498
|
+
_handleEvent<T extends TPointerEventNames>(e: FederatedPointerEvent, eventType: T, extraData?: TEventsExtraData[T]): void;
|
|
1499
|
+
/**
|
|
1500
|
+
* reset cache form common information needed during event processing
|
|
1501
|
+
* @private
|
|
1502
|
+
*/
|
|
1503
|
+
_resetTransformEventData(): void;
|
|
1504
|
+
/**
|
|
1505
|
+
* Cache common information needed during event processing
|
|
1506
|
+
* @private
|
|
1507
|
+
* @param {Event} e Event object fired on event
|
|
1508
|
+
*/
|
|
1509
|
+
_cacheTransformEventData(e: TPointerEvent): void;
|
|
1510
|
+
/**
|
|
1511
|
+
* Method that defines the actions when mouse is hovering the canvas.
|
|
1512
|
+
* The currentTransform parameter will define whether the user is rotating/scaling/translating
|
|
1513
|
+
* an image or neither of them (only hovering). A group selection is also possible and would cancel
|
|
1514
|
+
* all any other type of action.
|
|
1515
|
+
* In case of an image transformation only the top canvas will be rendered.
|
|
1516
|
+
* @private
|
|
1517
|
+
* @param {Event} e Event object fired on mousemove
|
|
1518
|
+
*/
|
|
1519
|
+
__onMouseMove(e: FederatedPointerEvent): void;
|
|
1520
|
+
/**
|
|
1521
|
+
* Manage the mouseout, mouseover events for the fabric object on the canvas
|
|
1522
|
+
* @param {Fabric.Object} target the target where the target from the mousemove event
|
|
1523
|
+
* @param {Event} e Event object fired on mousemove
|
|
1524
|
+
* @private
|
|
1525
|
+
*/
|
|
1526
|
+
private _fireOverOutEvents;
|
|
1527
|
+
/**
|
|
1528
|
+
* Manage the dragEnter, dragLeave events for the fabric objects on the canvas
|
|
1529
|
+
* @param {Fabric.Object} target the target where the target from the onDrag event
|
|
1530
|
+
* @param {Object} data Event object fired on dragover
|
|
1531
|
+
* @private
|
|
1532
|
+
*/
|
|
1533
|
+
_fireEnterLeaveEvents(e: FederatedPointerEvent, target: FabricObject | undefined, data: DragEventData): void;
|
|
1534
|
+
/**
|
|
1535
|
+
* @private
|
|
1536
|
+
* @param {Event} e Event fired on mousemove
|
|
1537
|
+
*/
|
|
1538
|
+
_transformObject(e: FederatedPointerEvent): void;
|
|
1539
|
+
/**
|
|
1540
|
+
* @private
|
|
1541
|
+
*/
|
|
1542
|
+
_performTransformAction(e: FederatedPointerEvent, transform: Transform, pointer: Point): void;
|
|
1543
|
+
/**
|
|
1544
|
+
* Sets the cursor depending on where the canvas is being hovered.
|
|
1545
|
+
* Note: very buggy in Opera
|
|
1546
|
+
* @param {Event} e Event object
|
|
1547
|
+
* @param {Object} target Object that the mouse is hovering, if so.
|
|
1548
|
+
*/
|
|
1549
|
+
_setCursorFromEvent(evt: FederatedPointerEvent, target?: FabricObject): void;
|
|
1550
|
+
/**
|
|
1551
|
+
* ## Handles multiple selection
|
|
1552
|
+
* - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)
|
|
1553
|
+
* - sets the active object in case it is not set or in case there is a single active object left under active selection.
|
|
1554
|
+
* ---
|
|
1555
|
+
* - If the active object is the active selection we add/remove `target` from it
|
|
1556
|
+
* - If not, add the active object and `target` to the active selection and make it the active object.
|
|
1557
|
+
* @TODO rewrite this after find target is refactored
|
|
1558
|
+
* @private
|
|
1559
|
+
* @param {TPointerEvent} e Event object
|
|
1560
|
+
* @param {FabricObject} target target of event to select/deselect
|
|
1561
|
+
* @returns true if grouping occurred
|
|
1562
|
+
*/
|
|
1563
|
+
protected handleMultiSelection(e: TPointerEvent, target?: FabricObject): boolean;
|
|
1564
|
+
private newCollectObjects;
|
|
1565
|
+
/**
|
|
1566
|
+
* ## Handles selection
|
|
1567
|
+
* - selects objects that are contained in (and possibly intersecting) the selection bounding box
|
|
1568
|
+
* - sets the active object
|
|
1569
|
+
* ---
|
|
1570
|
+
* runs on mouse up after a mouse move
|
|
1571
|
+
*/
|
|
1572
|
+
protected handleSelection(e: TPointerEvent): boolean;
|
|
850
1573
|
}
|
|
851
1574
|
|
|
852
1575
|
declare const CENTER = "center";
|
|
@@ -859,6 +1582,7 @@ declare const SKEWING = "skewing";
|
|
|
859
1582
|
declare const RESIZING = "resizing";
|
|
860
1583
|
declare const MODIFY_POLY = "modifyPoly";
|
|
861
1584
|
declare const MODIFY_PATH = "modifyPath";
|
|
1585
|
+
declare const MODIFIED = "modified";
|
|
862
1586
|
declare const NORMAL = "normal";
|
|
863
1587
|
|
|
864
1588
|
interface GroupEvents extends ObjectEvents, CollectionEvents {
|
|
@@ -1298,6 +2022,9 @@ declare const saveObjectTransform: (target: InnerObject) => {
|
|
|
1298
2022
|
top: number;
|
|
1299
2023
|
};
|
|
1300
2024
|
|
|
2025
|
+
type ModifierKey = 'altKey' | 'shiftKey' | 'ctrlKey' | 'metaKey';
|
|
2026
|
+
type TOptionalModifierKey = ModifierKey | null | undefined;
|
|
2027
|
+
type TPointerEventNames = WithBeforeSuffix<'down'> | WithBeforeSuffix<'move'> | WithBeforeSuffix<'up'> | 'click' | 'dblclick' | 'tripleclick' | 'wheel';
|
|
1301
2028
|
interface StaticCanvasEvents extends CollectionEvents {
|
|
1302
2029
|
'canvas:cleared': never;
|
|
1303
2030
|
'before:render': {
|
|
@@ -1313,9 +2040,117 @@ interface StaticCanvasEvents extends CollectionEvents {
|
|
|
1313
2040
|
target: Group;
|
|
1314
2041
|
};
|
|
1315
2042
|
}
|
|
1316
|
-
|
|
2043
|
+
type BeforeSuffix<T extends string> = `${T}:before`;
|
|
2044
|
+
type WithBeforeSuffix<T extends string> = T | BeforeSuffix<T>;
|
|
2045
|
+
interface InEvent {
|
|
2046
|
+
previousTarget?: FabricObject;
|
|
2047
|
+
}
|
|
2048
|
+
interface OutEvent {
|
|
2049
|
+
nextTarget?: FabricObject;
|
|
2050
|
+
}
|
|
2051
|
+
interface TPointerEventInfo<E extends TPointerEvent = TPointerEvent> extends TEvent<E> {
|
|
2052
|
+
target?: FabricObject;
|
|
2053
|
+
subTargets?: FabricObject[];
|
|
2054
|
+
transform?: Transform | null;
|
|
2055
|
+
scenePoint: Point;
|
|
2056
|
+
viewportPoint: Point;
|
|
2057
|
+
}
|
|
2058
|
+
type TPointerEvents<Prefix extends string> = Record<`${Prefix}${WithBeforeSuffix<'down'> | WithBeforeSuffix<'move'> | 'click' | 'dblclick' | 'tripleclick'}`, TPointerEventInfo> & Record<`${Prefix}down`, TPointerEventInfo & {
|
|
2059
|
+
/**
|
|
2060
|
+
* Indicates if the target or current target where already selected
|
|
2061
|
+
* before the cycle of mouse down -> mouse up started
|
|
2062
|
+
*/
|
|
2063
|
+
alreadySelected: boolean;
|
|
2064
|
+
}> & Record<`${Prefix}${WithBeforeSuffix<'up'>}`, TPointerEventInfo & {
|
|
2065
|
+
isClick: boolean;
|
|
2066
|
+
}> & Record<`${Prefix}wheel`, TPointerEventInfo<WheelEvent>> & Record<`${Prefix}over`, TPointerEventInfo & InEvent> & Record<`${Prefix}out`, TPointerEventInfo & OutEvent> & Record<'pinch', TPointerEventInfo & {
|
|
2067
|
+
scale: number;
|
|
2068
|
+
}> & Record<'rotate', TPointerEventInfo & {
|
|
2069
|
+
rotation: number;
|
|
2070
|
+
}>;
|
|
2071
|
+
interface DragEventData extends TEvent<DragEvent> {
|
|
2072
|
+
target?: FabricObject;
|
|
2073
|
+
subTargets?: FabricObject[];
|
|
2074
|
+
dragSource?: FabricObject;
|
|
2075
|
+
canDrop?: boolean;
|
|
2076
|
+
didDrop?: boolean;
|
|
2077
|
+
dropTarget?: FabricObject;
|
|
2078
|
+
}
|
|
2079
|
+
interface DnDEvents {
|
|
2080
|
+
dragstart: TPointerEventInfo;
|
|
2081
|
+
dragend: TPointerEventInfo;
|
|
2082
|
+
}
|
|
2083
|
+
interface CanvasDnDEvents extends DnDEvents {
|
|
1317
2084
|
}
|
|
1318
|
-
|
|
2085
|
+
type CanvasPointerEvents = TPointerEvents<'mouse:'>;
|
|
2086
|
+
interface MiscEvents {
|
|
2087
|
+
'contextmenu:before': SimpleEventHandler<Event>;
|
|
2088
|
+
contextmenu: SimpleEventHandler<Event>;
|
|
2089
|
+
}
|
|
2090
|
+
interface ModifyPathEvent {
|
|
2091
|
+
commandIndex: number;
|
|
2092
|
+
pointIndex: number;
|
|
2093
|
+
}
|
|
2094
|
+
type ObjectModificationEvents = {
|
|
2095
|
+
[MOVING]: BasicTransformEvent;
|
|
2096
|
+
[SCALING]: BasicTransformEvent;
|
|
2097
|
+
[ROTATING]: BasicTransformEvent;
|
|
2098
|
+
[SKEWING]: BasicTransformEvent;
|
|
2099
|
+
[RESIZING]: BasicTransformEvent;
|
|
2100
|
+
[MODIFY_POLY]: BasicTransformEvent;
|
|
2101
|
+
[MODIFY_PATH]: BasicTransformEvent & ModifyPathEvent;
|
|
2102
|
+
[MODIFIED]: ModifiedEvent;
|
|
2103
|
+
};
|
|
2104
|
+
type CanvasModificationEvents = {
|
|
2105
|
+
'before:transform': TEvent & {
|
|
2106
|
+
transform: Transform;
|
|
2107
|
+
};
|
|
2108
|
+
'object:moving': BasicTransformEvent & {
|
|
2109
|
+
target: FabricObject;
|
|
2110
|
+
};
|
|
2111
|
+
'object:scaling': BasicTransformEvent & {
|
|
2112
|
+
target: FabricObject;
|
|
2113
|
+
};
|
|
2114
|
+
'object:rotating': BasicTransformEvent & {
|
|
2115
|
+
target: FabricObject;
|
|
2116
|
+
};
|
|
2117
|
+
'object:skewing': BasicTransformEvent & {
|
|
2118
|
+
target: FabricObject;
|
|
2119
|
+
};
|
|
2120
|
+
'object:resizing': BasicTransformEvent & {
|
|
2121
|
+
target: FabricObject;
|
|
2122
|
+
};
|
|
2123
|
+
'object:modifyPoly': BasicTransformEvent & {
|
|
2124
|
+
target: FabricObject;
|
|
2125
|
+
};
|
|
2126
|
+
'object:modifyPath': BasicTransformEvent & {
|
|
2127
|
+
target: FabricObject;
|
|
2128
|
+
} & ModifyPathEvent;
|
|
2129
|
+
'object:modified': ModifiedEvent;
|
|
2130
|
+
};
|
|
2131
|
+
interface CanvasSelectionEvents {
|
|
2132
|
+
'selection:created': Partial<TEvent> & {
|
|
2133
|
+
selected: FabricObject[];
|
|
2134
|
+
};
|
|
2135
|
+
'selection:updated': Partial<TEvent> & {
|
|
2136
|
+
selected: FabricObject[];
|
|
2137
|
+
deselected: FabricObject[];
|
|
2138
|
+
};
|
|
2139
|
+
'before:selection:cleared': Partial<TEvent> & {
|
|
2140
|
+
deselected: FabricObject[];
|
|
2141
|
+
};
|
|
2142
|
+
'selection:cleared': Partial<TEvent> & {
|
|
2143
|
+
deselected: FabricObject[];
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
interface CanvasEvents extends StaticCanvasEvents, CanvasPointerEvents, CanvasDnDEvents, MiscEvents, CanvasModificationEvents, CanvasSelectionEvents {
|
|
2147
|
+
}
|
|
2148
|
+
interface SimpleEventHandler<T extends Event = TPointerEvent> extends TEvent<T> {
|
|
2149
|
+
target?: FabricObject;
|
|
2150
|
+
subTargets: FabricObject[];
|
|
2151
|
+
}
|
|
2152
|
+
type ObjectPointerEvents = TPointerEvents<'mouse'>;
|
|
2153
|
+
interface ObjectEvents extends ObjectPointerEvents, DnDEvents, MiscEvents, ObjectModificationEvents {
|
|
1319
2154
|
selected: Partial<TEvent> & {
|
|
1320
2155
|
target: FabricObject;
|
|
1321
2156
|
};
|
|
@@ -1386,6 +2221,13 @@ interface BasicTransformEvent<E extends Event = TPointerEvent> extends TEvent<E>
|
|
|
1386
2221
|
transform: Transform;
|
|
1387
2222
|
pointer: Point;
|
|
1388
2223
|
}
|
|
2224
|
+
interface BasicTransformEvent<E extends Event = TPointerEvent> extends TEvent<E> {
|
|
2225
|
+
transform: Transform;
|
|
2226
|
+
pointer: Point;
|
|
2227
|
+
}
|
|
2228
|
+
type TEventsExtraData = Record<PropertyKey, Record<PropertyKey, never>> & Record<'down', {
|
|
2229
|
+
alreadySelected: boolean;
|
|
2230
|
+
}>;
|
|
1389
2231
|
|
|
1390
2232
|
declare module 'pixi.js' {
|
|
1391
2233
|
interface Graphics {
|
|
@@ -1426,6 +2268,7 @@ declare class ObjectGeometry<EventSpec extends ObjectEvents = ObjectEvents> exte
|
|
|
1426
2268
|
angle: TDegree;
|
|
1427
2269
|
strokeWidth: number;
|
|
1428
2270
|
strokeUniform: boolean;
|
|
2271
|
+
protected hitArea: Rectangle;
|
|
1429
2272
|
constructor();
|
|
1430
2273
|
protected clearPixiContent(): void;
|
|
1431
2274
|
getCurGraphics(): Graphics;
|
|
@@ -1496,6 +2339,7 @@ declare class ObjectGeometry<EventSpec extends ObjectEvents = ObjectEvents> exte
|
|
|
1496
2339
|
calcOwnMatrix(): TMat2D;
|
|
1497
2340
|
calcTransformMatrix(skipGroup?: boolean): TMat2D;
|
|
1498
2341
|
getBoundingRect(): TBBox;
|
|
2342
|
+
set(key: string | Record<string, any>, value?: any): this;
|
|
1499
2343
|
}
|
|
1500
2344
|
|
|
1501
2345
|
declare class InnerObject<Props extends TOptions<ObjectProps> = Partial<ObjectProps>, SProps extends SerializedObjectProps = SerializedObjectProps, EventSpec extends ObjectEvents = ObjectEvents> extends ObjectGeometry<EventSpec> {
|
|
@@ -3597,5 +4441,5 @@ declare namespace index {
|
|
|
3597
4441
|
};
|
|
3598
4442
|
}
|
|
3599
4443
|
|
|
3600
|
-
export { Circle, Ellipse, FabricImage, FabricObject, FabricText, FakeCanvasRenderingContext2D, Group, FabricImage as Image, Line, Path, Point, Polygon, Polyline, Rect, StaticCanvas, FabricText as Text, Triangle, circleDefaultValues, ellipseDefaultValues, groupDefaultValues, polylineDefaultValues, rectDefaultValues, triangleDefaultValues, index as util };
|
|
4444
|
+
export { Canvas, Circle, Ellipse, FabricImage, FabricObject, FabricText, FakeCanvasRenderingContext2D, Group, FabricImage as Image, Line, Path, Point, Polygon, Polyline, Rect, StaticCanvas, FabricText as Text, Triangle, circleDefaultValues, ellipseDefaultValues, groupDefaultValues, polylineDefaultValues, rectDefaultValues, triangleDefaultValues, index as util };
|
|
3601
4445
|
export type { CircleProps, EllipseProps, GroupEvents, GroupOwnProps, GroupProps, IPathBBox, PathProps, RectProps, SerializedCircleProps, SerializedEllipseProps, SerializedGroupProps, SerializedLineProps, SerializedPathProps, SerializedPolylineProps, SerializedRectProps };
|