forked from plungingChode/svg.draw.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvg.draw.js.d.ts
84 lines (70 loc) · 2.22 KB
/
svg.draw.js.d.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
// Type definitions for @svgdotjs version 3.x
// Project: @svgdotjs/svg.draw.js
declare module '@svgdotjs/svg.js' {
interface DrawOptions {
snapToGrid?: number
drawCircles?: boolean
}
type DrawMethod =
| 'done'
| 'cancel'
| 'undo'
| 'stop'
| 'point'
| 'update'
interface DrawEvent {
detail: {
event: Event
p: SVGPoint
m: DOMMatrix
}
}
interface DrawEventMap {
'drawstart': DrawEvent
'drawstop': Event
'drawupdate': DrawEvent
'drawpoint': DrawEvent
'drawdone': Event
'drawcancel': Event
}
export interface Element {
draw(event?: Event, options?: DrawOptions): Element
/** Begin drawing with the provided `DrawOptions` */
draw(options?: DrawOptions): Element
/**
* Call a built-in method
*
* @example
* // Finishes the poly-shape
* polygon.draw('done');
*
* // Cancels drawing of a shape, removes it
* polygon.draw('cancel');
*
* // The following are only useful in edge-cases
*
* // Draws a new point with the help of a (mouse) event
* polygon.draw('point', event)
*
* // Draws the point while moving the mouse (basically the animation)
* polygon.draw('update', evnt)
*
* // Stop drawing, cleans up
* polygon.draw('stop', event)
*/
draw(method: DrawMethod, event?: Event): Element
/** Update options for a drawing in progress */
draw(method: 'param', key: any, value: any): Element
/** Call a method by name. May be used when drawing custom shapes. */
draw(method: string): Element
/** Attach an event listener to a `DrawEvent` type */
on<K extends keyof DrawEventMap>(type: K, listener: (this: Element, ev: DrawEventMap[K]) => any): this
on(type: string, listener: (this: Element, ev: Event) => any): this
/** Detach an event listener from a `DrawEvent` type */
off<K extends keyof DrawEventMap>(type: K, listener?: (this: Element, ev: DrawEventMap[K]) => any): this
/** Detach ALL event listeners from the `DrawEvent` type */
off<K extends keyof DrawEventMap>(type: K): this
off(type: string, listener?: (this: Element, ev: Event) => any): this
off(type: string): this
}
}