-
-
Notifications
You must be signed in to change notification settings - Fork 599
/
types.ts
3296 lines (3136 loc) · 81.8 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { IObject } from "@daybrush/utils";
import Gesto, * as GestoTypes from "gesto";
import CustomGesto from "./gesto/CustomGesto";
import { MOVEABLE_EVENTS_MAP, MOVEABLE_PROPS_MAP } from "./ables/consts";
import { MoveableTargetInfo } from "./utils/getMoveableTargetInfo";
import { DragScrollOptions } from "@scena/dragscroll";
export interface MoveableClientRect {
left: number;
top: number;
right: number;
bottom: number;
width: number;
height: number;
clientLeft?: number;
clientTop?: number;
clientWidth?: number;
clientHeight?: number;
scrollWidth?: number;
scrollHeight?: number;
overflow?: boolean;
}
export type MoveableManagerProps<T = {}> = {
cssStyled: any;
customStyledMap: Record<string, any>;
wrapperMoveable?: MoveableManagerInterface | null;
isWrapperMounted?: boolean;
parentMoveable?: MoveableManagerInterface | null;
parentPosition?: number[] | null;
groupable?: boolean;
} & MoveableDefaultOptions & (unknown extends T ? IObject<any> : T);
export type AnyObject<T> = (unknown extends T ? IObject<any> : T);
/**
* @typedef
* @memberof Moveable
*/
export interface MoveablePosition {
left: number;
top: number;
right: number;
bottom: number;
origin: number[];
pos1: number[];
pos2: number[];
pos3: number[];
pos4: number[];
direction: 1 | -1;
}
/**
* @typedef
* @memberof Moveable
* @options
*/
export interface DefaultOptions {
/**
* The target(s) to indicate Moveable Control Box.
* @default null
*/
target?: SVGElement | HTMLElement | null;
/**
* The target(s) to drag Moveable target(s)
* @default target
*/
dragTarget?: SVGElement | HTMLElement | null;
/**
* Moveable Container. Don't set it.
* @private
* @default parentElement
*/
container?: SVGElement | HTMLElement | null;
/**
* Moveable Portal Container to support other frameworks. Don't set it.
* @private
* @default parentElement
*/
portalContainer?: HTMLElement | null;
/**
* Moveable Root Container (No Transformed Container)
* @default parentElement
* @story options--use-rootcontainer-with-transformed-container-css-transform
*/
rootContainer?: MoveableRefType<HTMLElement>;
/**
* If you want to set the dragging information to the viewer, refer to the following.
* @default null
* @story options--cursor-is-applied-in-viewer-during-dragging
*/
viewContainer?: MoveableRefType<HTMLElement>;
/**
* Whether the target size is detected and updated whenever it changes.
* @default false
* @story options--useresizeobserver
*/
useResizeObserver?: boolean;
/**
* Zooms in the elements of a moveable.
* @default 1
*/
zoom?: number;
/**
* The default transformOrigin of the target can be set in advance.
* @default ""
*/
transformOrigin?: Array<string | number> | string | "";
/**
* You can add your custom able.
* @default []
*/
ables?: Able[];
/**
* You can specify the className of the moveable controlbox.
* @default ""
*/
className?: string;
/**
* Minimum distance to pinch.
* @default 20
*/
pinchThreshold?: number;
/**
* Whether the container containing the target becomes a pinch.
* @default true
*/
pinchOutside?: boolean;
/**
* Lets generate events of ables at the same time. (like Resizable, Scalable)
* @default false
*/
triggerAblesSimultaneously?: boolean;
/**
* Checks whether this is an element to input text or contentEditable, and prevents dragging.
* @default false
*/
checkInput?: boolean;
/**
* add nonce property to style for CSP.
* @deprecated
* @default ""
*/
cspNonce?: string;
/**
* You can set the translateZ value of moveable.
* @default 50
*/
translateZ?: number | string;
/**
* Whether to hide the line corresponding to the rect of the target.
* @default false
*/
hideDefaultLines?: boolean;
/**
* Whether to prevent bubbling of events like mousedown, touchstart, etc.
* @default false
*/
stopPropagation?: boolean;
/**
* Whether to call preventDefault on touchstart or mousedown
* @since 0.44.0
* @default true
*/
preventDefault?: boolean;
/**
* Prevent click event on drag. (mousemove, touchmove)
* @default true
*/
preventClickEventOnDrag?: boolean;
/**
* Prevent click event on dragStart. (mousedown, touchstart)
* @default false
*/
preventClickDefault?: boolean;
/**
* You can use props in object format or custom props.
* @default empty object
*/
props?: Record<string, any>;
/**
* Data for first render
* @default null
*/
persistData?: PersistRectData | null;
/**
* Whether to accurately show the position of a movable control box
* Because getBoundingClientRect is used, css zoom, transform: rotate between container and rootContainer cannot be used.
* group is not supported.
* @default false
*/
useAccuratePosition?: boolean;
/**
* By adding padding to the line, you can increase the area of the line that can be clicked and dragged.
* @since 0.43.0
* @story options--linepadding
* @default 0
*/
linePadding?: number;
/**
* By adding padding to the control, you can increase the area of the control that can be clicked and dragged.
* Either `rotateAroundControls` or `displayAroundControls` can be used.
* @since 0.44.0
* @story options--controlPadding
* @default 0
*/
controlPadding?: number;
/**
* @private
* single => group로 변환과정에 도형 유지를 위한 첫 렌더링 state
*/
firstRenderState?: MoveableManagerState | null;
/**
* @private
*/
requestStyles?: string[];
/**
* If you are using React 18's concurrent mode, use `flushSync` for UI sync.
* @default empty function
* @example
* ```jsx
* import { flushSync } from "react-dom";
*
* <Moveable flushSync={flushSync} />
* ```
*/
flushSync?: (callback: () => void) => void;
}
/**
* @typedef
* @extends Moveable.DefaultOptions
* @extends Moveable.DragAreaOptions
* @extends Moveable.OriginOptions
* @extends Moveable.PaddingOptions
*/
export interface MoveableDefaultOptions
extends DefaultOptions, DragAreaOptions, OriginOptions, PaddingOptions {
}
export interface MatrixInfo {
type: "offset" | "target" | "zoom";
target: SVGElement | HTMLElement;
matrix?: number[];
origin?: number[];
zoom?: number;
}
export type MoveableManagerState<T = {}> = {
container: SVGElement | HTMLElement | null | undefined;
disableNativeEvent: boolean;
gestos: Record<string, Gesto | CustomGesto | null>;
renderPoses: number[][];
posDelta: number[];
style: Partial<Writable<CSSStyleDeclaration>>;
isPersisted?: boolean;
} & MoveableTargetInfo & T;
/**
* @typedef
* @memberof Moveable
*/
export interface ElementSizes {
svg: boolean;
offsetWidth: number;
offsetHeight: number;
clientWidth: number;
clientHeight: number;
inlineCSSWidth: number;
inlineCSSHeight: number;
cssWidth: number;
cssHeight: number;
contentWidth: number;
contentHeight: number;
minWidth: number;
minHeight: number;
maxWidth: number;
maxHeight: number;
minOffsetWidth: number;
minOffsetHeight: number;
maxOffsetWidth: number;
maxOffsetHeight: number;
}
/**
* @typedef
* @memberof Moveable
*/
export type LineDirection = "n" | "e" | "s" | "w" | "nw" | "ne" | "sw" | "se";
/**
* @typedef
* @memberof Moveable
* @property - left padding
* @property - top padding
* @property - right padding
* @property - bottom padding
*/
export interface PaddingBox {
left?: number;
top?: number;
right?: number;
bottom?: number;
}
export interface Renderer {
createElement(type: any, props?: any, ...children: any[]): any;
}
/**
* @typedef
* @memberof Moveable.Snappable
*/
export interface SnapGuideline {
type: "horizontal" | "vertical";
hide?: boolean;
element?: Element | null;
isStart?: boolean;
isEnd?: boolean;
isCenter?: boolean;
isInner?: boolean;
pos: number[];
size: number;
className?: string;
sizes?: number[];
gap?: number;
elementRect?: SnapElementRect;
gapRects?: SnapElementRect[];
}
export interface SnapBoundInfo {
isBound: boolean;
isSnap: boolean;
offset: number;
dist: number;
snapIndex?: number;
bounds?: BoundInfo[];
snap?: SnapInfo;
}
export interface BoundInfo {
isBound: boolean;
offset: number;
pos: number;
}
export interface SnapOffsetInfo {
isSnap: boolean;
offset: number;
pos: number;
}
export interface SnapInfo {
isSnap: boolean;
index: number;
posInfos: SnapPosInfo[];
}
export interface SnapPosInfo {
pos: number;
index: number;
guidelineInfos: SnapGuidelineInfo[];
}
export interface SnapGuidelineInfo {
dist: number;
offset: number;
guideline: SnapGuideline;
}
/**
* @typedef
* @memberof Moveable.Snappable
*/
export interface RenderGuidelineInfo {
key?: string;
direction: string;
classNames: string[];
size: string;
pos: string[];
sizeValue: number;
posValue: number[];
zoom: number;
}
export interface RenderGuidelineInnerInfo {
key?: string;
direction: string;
classNames: Array<string | undefined>;
size?: string;
pos?: string[];
sizeValue: number;
posValue: number[];
zoom: number;
}
export type ExcludeKeys<T extends IObject<any>, U> = Pick<T, Exclude<keyof T, U>>;
export interface MoveableProps extends
MoveableDefaultProps,
DraggableProps,
DragAreaProps,
OriginDraggableProps,
RotatableProps,
ResizableProps,
ScalableProps,
WarpableProps,
PinchableProps,
ExcludeKeys<GroupableProps, "targets" | "updateGroup">,
IndividualGroupableProps,
SnappableProps,
ScrollableProps,
ClippableProps,
RoundableProps,
BeforeRenderableProps,
ClickableProps,
RenderableProps {
}
/**
* @memberof Moveable
* @typedef
* @extends Moveable.MoveableDefaultOptions
*/
export interface MoveableDefaultProps extends ExcludeKeys<MoveableDefaultOptions, "target"> {
target?: MoveableRefTargetType;
onChangeTargets?: (e: OnChangeTargets) => void;
}
/**
* @memberof Moveable
* @typedef
*/
export type MoveableRefTargetType = MoveableRefType | ArrayFormat<MoveableRefTargetType>;
export type MoveableRefTargetsResultType
= Array<HTMLElement | SVGElement | string | null | MoveableRefTargetsResultType>;
/**
* @memberof Moveable
* @typedef
*/
export type MoveableRefType<T extends Element = HTMLElement | SVGElement>
= string | (() => T) | MoveableRefObject<T> | T | null | undefined;
/**
* @memberof Moveable
* @typedef
*/
export interface MoveableRefObject<T extends Element = HTMLElement | SVGElement> {
current: T | undefined | null;
}
/**
* @memberof Moveable
* @typedef
* @extends Moveable.MoveableDefaultProps
* @extends Moveable.Draggable.DraggableOptions
* @extends Moveable.Resizable.ResizableOptions
* @extends Moveable.Scalable.ScalableOptions
* @extends Moveable.Rotatable.RotatableOptions
* @extends Moveable.Warpable.WarpableOptions
* @extends Moveable.Pinchable.PinchableOptions
* @extends Moveable.Group.GroupableOptions
* @extends Moveable.OriginDraggable.OriginDraggableOptions
* @extends Moveable.Scrollable.ScrollableOptions
* @extends Moveable.Clippable.ClippableOptions
* @extends Moveable.Roundable.RoundableOptions
* @extends Moveable.Clickable.ClickableOptions
*/
export interface MoveableOptions extends
MoveableDefaultProps,
DraggableOptions,
DragAreaOptions,
OriginDraggableOptions,
RotatableOptions,
ResizableOptions,
ScalableOptions,
WarpableOptions,
PinchableOptions,
GroupableOptions,
IndividualGroupableOptions,
SnappableOptions,
ScrollableOptions,
ClippableOptions,
RoundableOptions,
ClickableOptions {
}
export type MoveableState = MoveableManagerState;
/**
* You can make Able that can work in Moveable.
* @typedef
* In Able, you can manage drag events, props, state, fire event props, and render elements.
* @memberof Moveable
*/
export interface Able<Props extends IObject<any> = IObject<any>, Events extends IObject<any> = IObject<any>> {
name: string;
props?: { [key in keyof Props]: any };
events?: { [key in keyof Events]: string };
// Whether to always include in able. It is recommended to use always in frameworks other than react
always?: boolean;
ableGroup?: string;
updateRect?: boolean;
canPinch?: boolean;
css?: string[];
/**
* You can request style. Specify the name of the style in camel case.
* You can check it with `moveable.state.style`
* @exmaple
* ["borderRadius", "top", "left"]
*/
requestStyle?(): string[];
/**
* If you use group, you can request child style. Specify the name of the style in camel case.
* You can check it with `moveable.state.style`
* @exmaple
* ["borderRadius", "top", "left"]
*/
requestChildStyle?(): string[];
/**
* You can specify the class name to be added to the Moveable control box.
*/
className?(moveable: any): string;
/**
* You can specify the class name to be added to the Moveable View Container
*/
viewClassName?(moveable: any): string;
/**
* Check how related to drag
*/
dragRelation?: "strong" | "weak" | undefined | null | false,
/**
* Fired when the event is cleared
*/
unset?(moveable: any): any;
/**
* Renders the React DOM structure for the able.
*/
render?(moveable: any, renderer: Renderer): any;
// Operates when a drag event occurs for the single target.
dragStart?(moveable: any, e: any): any;
drag?(moveable: any, e: any): any;
dragEnd?(moveable: any, e: any): any;
dragAfter?(moveable: any, e: any): any;
// Operates when a pinch event occurs for the single target.
pinchStart?(moveable: any, e: GestoTypes.OnPinchStart): any;
pinch?(moveable: any, e: GestoTypes.OnPinch): any;
pinchEnd?(moveable: any, e: GestoTypes.OnPinchEnd): any;
// Condition that occurs dragControl
dragControlCondition?(moveable: any, e: any): boolean;
// Operates when a drag event occurs for the moveable control and single target.
dragControlStart?(moveable: any, e: any): any;
dragControl?(moveable: any, e: any): any;
dragControlEnd?(moveable: any, e: any): any;
dragControlAfter?(moveable: any, e: any): any;
// Condition that occurs dragGroup
dragGroupCondition?(moveable: any, e: any): boolean;
// Operates when a drag event occurs for the multi target.
dragGroupStart?(moveable: any, e: any): any;
dragGroup?(moveable: any, e: any): any;
dragGroupEnd?(moveable: any, e: any): any;
// Operates when a pinch event occurs for the multi target.
pinchGroupStart?(moveable: any, e: GestoTypes.OnPinchStart): any;
pinchGroup?(moveable: any, e: GestoTypes.OnPinch): any;
pinchGroupEnd?(moveable: any, e: GestoTypes.OnPinchEnd): any;
// Condition that occurs dragGroupControl
dragGroupControlCondition?(moveable: any, e: any): boolean;
// Operates when a drag event occurs for the moveable control and multi target.
dragGroupControlStart?(moveable: any, e: any): any;
dragGroupControl?(moveable: any, e: any): any;
dragGroupControlEnd?(moveable: any, e: any): any;
// mouse enter event
mouseEnter?(moveable: any, e: any): any;
// mouse leave event
mouseLeave?(moveable: any, e: any): any;
// mouse enter event for group
mouseGroupEnter?(moveable: any, e: any): any;
// mouse leave event for group
mouseGroupLeave?(moveable: any, e: any): any;
// Execute the operation of able for external request
request?(moveable: any): AbleRequester;
}
/**
* @typedef
* @memberof Moveable
*/
export interface OnEvent {
/**
* The Moveable instance
*/
currentTarget: MoveableManagerInterface<any, any>;
/**
* The Moveable instance
*/
moveable: MoveableManagerInterface<any, any>;
/**
* The Moveable's target
*/
target: HTMLElement | SVGElement;
/**
* The horizontal coordinate within the application's client area at which the event occurred.
*/
clientX: number;
/**
* The vertical coordinate within the application's client area at which the event occurred.
*/
clientY: number;
/**
* Whether this is the first drag in the drag event
*/
isFirstDrag: number;
/**
* Objects that can send information to the following events.
*/
datas: IObject<any>;
/**
* The mouse or touch input event that is invoking the moveable event
*/
inputEvent: any;
/**
* Stop the currently working able.
*/
stopAble(): void;
/**
* Calling `stopDrag` in a drag-related event ends the drag.
*/
stopDrag(): void;
/**
* Whether the event did not occur externally
*/
isTrusted: boolean;
}
/**
* @typedef
* @memberof Moveable
* @extends Moveable.OnEvent
* @property - This is the last dragged event. No, if you haven't dragged.
* @property - Whether this moved
* @property - Whether it is double-click
*/
export interface OnEndEvent extends OnEvent {
lastEvent: any | undefined;
isDrag: boolean;
isDouble: boolean;
}
/**
* @typedef
* @memberof Moveable
*/
export interface OnTransformStartEvent {
/**
* Set your original transform.
* `transformIndex` is the sequence of functions used in the event.
* If you use `setTransform`, you don't need to use `set` function.
* @default transform of target's inline style
*/
setTransform(transform: string | string[], transformIndex?: number): void;
/**
* `transformIndex` is the sequence of functions used in the event.
* @default index with that property in transform or last
*/
setTransformIndex(transformIndex: number): void;
}
/**
* @typedef
* @memberof Moveable
* @extends Moveable.CSSObject
*/
export interface TransformObject extends CSSObject {
/**
* a target's next transform string value.
*/
transform: string;
/**
* A transform obtained by the simultaneous occurrence of other events in the current event
*/
afterTransform: string;
}
/**
* @typedef
* @memberof Moveable
* @extends Moveable.TransformObject
*/
export interface OnTransformEvent extends TransformObject {
/**
* transform events causes a `drag` event. In some events, there may be no value.
*/
drag: OnDrag;
}
/**
* @typedef
* @memberof Moveable
*/
export interface AbleRequestParam {
/**
* Run the request instantly. (requestStart, request, requestEnd happen at the same time)
*/
isInstant?: boolean;
[key: string]: any;
}
/**
* @typedef
* @memberof Moveable
* @see {@link https://daybrush.com/moveable/release/latest/doc/Moveable.html#request|Request Method}
* @see {@link https://daybrush.com/moveable/release/latest/doc/Moveable.Draggable.html#request|Draggable Requester}
* @see {@link https://daybrush.com/moveable/release/latest/doc/Moveable.Resizable.html#request|Resizable Requester}
* @see {@link https://daybrush.com/moveable/release/latest/doc/Moveable.Scalable.html#request|Scalable Requester}
* @see {@link https://daybrush.com/moveable/release/latest/doc/Moveable.Rotatable.html#request|Rotatable Requester}
* @property - Continue executing the request.
* @property - End the request.
*/
export interface Requester<RequestParam extends {} = AbleRequestParam> {
request(param: RequestParam): this;
requestEnd(): this;
}
export interface AbleRequester {
isControl: boolean;
requestStart(param: IObject<any>): IObject<any>;
request(param: IObject<any>): IObject<any>;
requestEnd(): IObject<any>;
}
/**
* @typedef
* @memberof Moveable
*/
export interface OnChangeTargets {
/**
* The Moveable instance
*/
moveable: MoveableManagerInterface<any, any>;
/**
* The Moveable's targets
*/
targets: Array<HTMLElement | SVGElement>;
}
/**
* @typedef
* @memberof Moveable.Pinchable
* @extends Moveable.OnEvent
*/
export interface OnPinchStart extends OnEvent {
}
/**
* @typedef
* @memberof Moveable.Pinchable
* @extends Moveable.OnEvent
*/
export interface OnPinch extends OnEvent {
}
/**
* @typedef
* @memberof Moveable.Pinchable
* @extends Moveable.OnEndEvent
*/
export interface OnPinchEnd extends OnEndEvent { }
/**
* When the drag starts, the dragStart event is called.
* @typedef
* @memberof Moveable.Draggable
* @extends Moveable.OnEvent
* @extends Moveable.OnTransformStartEvent
*/
export interface OnDragStart extends OnEvent, OnTransformStartEvent {
/**
* You can set the start translate value.
*/
set: (translate: number[]) => void;
}
/**
* @typedef
* @memberof Moveable.Draggable
* @extends Moveable.OnEvent
* @extends Moveable.CSSObject
* @property - The delta of [left, top]
* @property - The distance of [left, top]
* @property - The position of [left, top]
* @property - The delta of [translateX, translateY]
* @property - The distance of [translateX, translateY]
* @property - The position of [translateX, translateY]
* @property - a target's transform
* @property - a target's left
* @property - a target's top
* @property - a target's bottom
* @property - a target's offset width
* @property - a target's offset height
* @property - a target's right
* @property - Whether or not it is being pinched.
*/
export interface OnDrag extends OnEvent, CSSObject {
beforeDelta: number[];
beforeDist: number[];
beforeTranslate: number[];
delta: number[];
dist: number[];
translate: number[];
transform: string;
left: number;
top: number;
bottom: number;
width: number;
height: number;
right: number;
isPinch: boolean;
}
/**
* @typedef
* @memberof Moveable.Draggable
* @extends Moveable.OnEndEvent
*/
export interface OnDragEnd extends OnEndEvent {
}
/**
* @typedef
* @memberof Moveable.OriginDraggable
* @extends Moveable.OnEvent
* @property - dragOrigin causes a `dragStart` event.
*/
export interface OnDragOriginStart extends OnEvent {
dragStart: OnDragStart | false;
}
/**
* @typedef
* @memberof Moveable.OriginDraggable
* @extends Moveable.OnEvent
* @extends Moveable.CSSObject
*/
export interface OnDragOrigin extends OnEvent, CSSObject {
/**
* Offset width of target
*/
width: number;
/**
* Offset height of target
*/
height: number;
/**
* The delta of [x, y]
*/
delta: number[];
/**
* The distance of [x, y]
*/
dist: number[];
/**
* The target's moved transform-origin poses
*/
origin: number[];
/**
* The target's moved transform-origin css
*/
transformOrigin: string;
/**
* A transform obtained by the simultaneous occurrence of other events in the current event
*/
afterTransform: string;
/**
* `dragOrigin` causes a `drag` event.
*/
drag: OnDrag;
}
/**
* @typedef
* @memberof Moveable.OriginDraggable
* @extends Moveable.OnEndEvent
*/
export interface OnDragOriginEnd extends OnEndEvent {
}
/**
* @typedef
* @memberof Moveable.Roundable
* @extends Moveable.OnEvent
*/
export interface OnRoundStart extends OnEvent { }
/**
* @typedef
* @memberof Moveable.Roundable
* @extends Moveable.OnEvent
* @extends Moveable.CSSObject
* @property - Offset width of target
* @property - Offset height of target
* @property - The delta of [x, y]
* @property - The distance of [x, y]
* @property - The target's moved border-radius's horizontal poses
* @property - The target's moved border-radius's vertical poses
* @property - The target's moved border-radius
*/
export interface OnRound extends OnEvent, CSSObject {
width: number;
height: number;
delta: number[];
dist: number[];
horizontals: number[];
verticals: number[];
borderRadius: string;
}
/**
* @typedef
* @memberof Moveable.Roundable
* @extends Moveable.OnEndEvent
*/
export interface OnRoundEnd extends OnEndEvent {
}
/**
* @typedef
* @memberof Moveable.Roundable
* @extends Moveable.OnRoundStart
*/
export interface OnRoundGroupStart extends OnRoundStart {
/**
* moveable's targets
*/
targets: Array<HTMLElement | SVGElement>;
/**
* moveable's child events
*/
events: OnRoundStart[];
}
/**
* @typedef
* @memberof Moveable.Roundable
* @extends Moveable.OnRound
*/
export interface OnRoundGroup extends OnRound {
/**
* moveable's targets
*/
targets: Array<HTMLElement | SVGElement>;
/**
* moveable's child events
*/
events: OnRound[];
}
/**
* @typedef
* @memberof Moveable.Roundable
* @extends Moveable.OnRoundEnd
*/
export interface OnRoundGroupEnd extends OnRoundEnd {
/**
* moveable's targets
*/
targets: Array<HTMLElement | SVGElement>;
/**
* moveable's child events
*/
events: OnRoundEnd[];
}
/**
* @typedef
* @memberof Moveable.Scalable
* @extends Moveable.OnEvent
* @extends Moveable.OnTransformStartEvent
*/
export interface OnScaleStart extends OnEvent, OnTransformStartEvent {
/**
* The direction of scale.
*/
direction: number[];
/**
* scale causes a `dragStart` event.
*/
dragStart: OnDragStart | false;
/**
* You can set the start scale value.
*/
set: (scale: number[]) => void;
/**
* Set a fixed direction to scale.
* @default Opposite direction
*/
setFixedDirection: (startDirecition: number[]) => void;
/**
* Set the ratio of width and height.
* @default offsetWidth / offsetHeight
*/
setRatio: (ratio: number) => any;
}
/**
* @typedef
* @memberof Moveable.Scalable