Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch(TS): canvas patch init 2 #8520

Merged
merged 40 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7c83395
broken progress
asturur Dec 12, 2022
fdf9245
save work
asturur Dec 12, 2022
aa0b140
save progress work
asturur Dec 17, 2022
6c02e74
may i have broke stuff
asturur Dec 17, 2022
84541aa
what did i do
asturur Dec 17, 2022
135ef2a
something killed fabric.config
asturur Dec 18, 2022
54e6351
stupid vscode you killed a full evening
asturur Dec 18, 2022
5ba11af
test passing
asturur Dec 18, 2022
47d717b
minimal changes
asturur Dec 18, 2022
305d6e8
clean up canvas
asturur Dec 18, 2022
1c577f3
patch canvas init logic
ShaMan123 Dec 18, 2022
286967c
fix(): apply canvas style before saving `_originalCanvasStyle`
ShaMan123 Dec 18, 2022
efcf9f1
cleanup redundant call
ShaMan123 Dec 18, 2022
644f94f
Revert "fix(): apply canvas style before saving `_originalCanvasStyle`"
ShaMan123 Dec 18, 2022
c31e5d7
rm redundant objects init
ShaMan123 Dec 19, 2022
281b831
mv
ShaMan123 Dec 19, 2022
9818c73
rm render bound methods
ShaMan123 Dec 19, 2022
143c4cc
test
ShaMan123 Dec 19, 2022
a9c7c7a
Update canvas.js
ShaMan123 Dec 19, 2022
fe21142
Merge branch 'master' into ts-canvas-patch-init
ShaMan123 Dec 29, 2022
4971d73
restore
ShaMan123 Dec 29, 2022
2abdf9a
dump _initEventListeners
ShaMan123 Dec 29, 2022
9ca6002
dump _bindEvents
ShaMan123 Dec 29, 2022
f5e96ca
Update CHANGELOG.md
ShaMan123 Dec 29, 2022
cba9325
fix(): regression unwanted init retina
ShaMan123 Jan 3, 2023
6e1ddc1
Merge branch 'master' into ts-canvas-patch-init
ShaMan123 Jan 3, 2023
359606c
Update CHANGELOG.md
ShaMan123 Jan 3, 2023
65afac6
fix(): set elements size on init
ShaMan123 Jan 3, 2023
b27ac06
forgotten
ShaMan123 Jan 3, 2023
fadd45f
rerfactor(): rm initSize => setDimensions
ShaMan123 Jan 3, 2023
95cc420
fix
ShaMan123 Jan 3, 2023
a1e89a7
cleanup + protected
ShaMan123 Jan 3, 2023
1d848ee
Update canvas.js
ShaMan123 Jan 4, 2023
15c8bf7
Merge branch 'master' into ts-canvas-patch-init
ShaMan123 Jan 6, 2023
a3caeac
Merge branch 'master' into ts-canvas-patch-init
asturur Jan 14, 2023
7c4910d
fix(): bad merge
ShaMan123 Jan 15, 2023
d8557f3
first commit
asturur Jan 15, 2023
e6148fc
changes to setDimensions
asturur Jan 15, 2023
e1ffe0c
mantain terser bind code
asturur Jan 15, 2023
9d19204
of course prettier
asturur Jan 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- chore(TS): Convert Canvas class #8510
- chore(TS): Move object classes #8511
- chore(TS): polish text [#8489](https://github.com/fabricjs/fabric.js/pull/8489)
- chore(TS): fix import cycle, extract `groupSVGElements` [#8506](https://github.com/fabricjs/fabric.js/pull/8506)
Expand Down
39 changes: 24 additions & 15 deletions src/EventTypeDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ import type { Canvas } from './__types__';
import type { IText } from './shapes/itext.class';
import type { StaticCanvas } from './static_canvas.class';

export type ModifierKey = 'altKey' | 'shiftKey' | 'ctrlKey';
export type ModifierKey = keyof Pick<
MouseEvent | PointerEvent | TouchEvent,
'altKey' | 'shiftKey' | 'ctrlKey' | 'metaKey'
>;

export type TOptionalModifierKey = ModifierKey | null | undefined;

export type TPointerEvent = MouseEvent | TouchEvent;
export type TPointerEvent = MouseEvent | TouchEvent | PointerEvent;

export type TransformAction<T extends Transform = Transform, R = void> = (
eventData: TPointerEvent,
Expand Down Expand Up @@ -38,7 +43,7 @@ export type Transform = {
target: FabricObject;
action: string;
actionHandler: TransformActionHandler;
corner: string;
corner: string | 0;
scaleX: number;
scaleY: number;
skewX: number;
Expand All @@ -56,13 +61,20 @@ export type Transform = {
height: number;
shiftKey: boolean;
altKey: boolean;
original: ReturnType<typeof saveObjectTransform>;
original: ReturnType<typeof saveObjectTransform> & {
originX: TOriginX;
originY: TOriginY;
};
};

export type TEvent<E extends Event = TPointerEvent> = {
e: E;
};

type TEventWithTarget<E extends Event = TPointerEvent> = TEvent<E> & {
target: FabricObject;
};

export type BasicTransformEvent<E extends Event = TPointerEvent> = TEvent<E> & {
transform: Transform;
pointer: Point;
Expand Down Expand Up @@ -94,10 +106,10 @@ export type TransformEvent<T extends Event = TPointerEvent> =
absolutePointer: Point;
};

type SimpleEventHandler<T extends Event = TPointerEvent> = TEvent<T> & {
target: FabricObject;
subTargets: FabricObject[];
};
type SimpleEventHandler<T extends Event = TPointerEvent> =
TEventWithTarget<T> & {
subTargets: FabricObject[];
};

type InEvent = {
previousTarget?: FabricObject;
Expand All @@ -107,8 +119,7 @@ type OutEvent = {
nextTarget?: FabricObject;
};

type DragEventData = TEvent<DragEvent> & {
target: FabricObject;
type DragEventData = TEventWithTarget<DragEvent> & {
subTargets?: FabricObject[];
dragSource?: FabricObject;
canDrop?: boolean;
Expand All @@ -118,7 +129,7 @@ type DragEventData = TEvent<DragEvent> & {
type DropEventData = DragEventData & { pointer: Point };

type DnDEvents = {
dragstart: TEvent<DragEvent> & { target: FabricObject };
dragstart: TEventWithTarget<DragEvent>;
drag: DragEventData;
dragover: DragEventData;
dragenter: DragEventData & InEvent;
Expand Down Expand Up @@ -177,12 +188,10 @@ export type ObjectEvents = ObjectPointerEvents &
DnDEvents &
ObjectModifiedEvents & {
// selection
selected: {
e: TEvent;
selected: Partial<TEvent> & {
target: FabricObject;
};
deselected: {
e?: TEvent;
deselected: Partial<TEvent> & {
target: FabricObject;
};

Expand Down
Loading