forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
svg-pan-zoom.d.ts
151 lines (113 loc) · 4.19 KB
/
svg-pan-zoom.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
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
// Type definitions for svg-pan-zoom v2.3.9
// Project: https://github.com/ariutta/svg-pan-zoom
// Definitions by: Chintan Shah <https://github.com/Promact>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace SvgPanZoom {
interface OptionConfig {
panEnabled?: boolean; // enable or disable panning (default enabled)
controlIconsEnabled?: boolean; // insert icons to give user an option in addition to mouse events to control pan/zoom (default disabled)
zoomEnabled?: boolean; // enable or disable zooming (default enabled)
dblClickZoomEnabled?: boolean; // enable or disable zooming by double clicking (default enabled)
zoomScaleSensitivity?: number; // Zoom sensitivity
minZoom?: number; // Minimum Zoom level
maxZoom?: number; // Maximum Zoom level
fit?: boolean; // enable or disable viewport fit in SVG (default true)
center?: boolean; // enable or disable viewport centering in SVG (default true)
beforeZoom?: (scale:number) => void;
onZoom?: (scale:number) => void;
beforePan?: (point:IPoint) => void;
onPan?: (x:number, y:number) => void;
refreshRate?: any; // in hz
}
interface IPoint {
x: number;
y: number;
}
interface ISvgPanZoom {
/**
* Creates a new SvgPanZoom instance with given element selector.
*
* @param svg selector of the tag on which it is to be applied.
* @param options provides customization options at the initialization of the object.
*/
(svg:any, options?:OptionConfig): ISvgPanZoom;
/**
* Enables Panning on svg element
*/
enablePan(): void;
/**
* Disables panning on svg element
*/
disablePan(): void;
/**
* Checks if Panning is enabled or not
* @return true or false based on panning settings
*/
isPanEnabled(): boolean;
setBeforePan(fn: (point:IPoint)=> void): void;
setOnPan(fn: (x:number, y:number)=> void): void;
enableZoom(): void;
disableZoom(): void;
isZoomEnabled(): boolean;
enableControlIcons(): void;
disableControlIcons(): void;
isControlIconsEnabled(): boolean;
enableDblClickZoom(): void;
disableDblClickZoom(): void;
setZoomScaleSensitivity(scale: number): void;
setMinZoom(zoom: number): void;
setMaxZoom(zoom: number): void;
setBeforeZoom(fn: (scale: number) => void): void;
setOnZoom(fn: (scale: number) => void): void;
zoom(scale: number):void;
zoomIn(): void;
zoomOut(): void;
zoomBy(scale: number): void;
resetZoom(): void;
/**
* Get zoom scale/level
*
* @return {float} zoom scale
*/
getZoom(): number;
/**
* Adjust viewport size (only) so it will fit in SVG
* Does not center image
*
* @param {bool} dropCache drop viewBox cache and recalculate SVG's viewport sizes. Default false
*/
fit(dropCache?: boolean): void;
/**
* Adjust viewport pan (only) so it will be centered in SVG
* Does not zoom/fit image
*
* @param {bool} dropCache drop viewBox cache and recalculate SVG's viewport sizes. Default false
*/
center(dropCache?: boolean): void;
/**
* Recalculates cached svg dimensions and controls position
*/
resize(): void;
/**
* Pan to a rendered position
*
* @param {object} point {x: 0, y: 0}
*/
pan(point: IPoint): void;
/**
* Relatively pan the graph by a specified rendered position vector
*
* @param {object} point {x: 0, y: 0}
*/
panBy(point: IPoint): void;
/**
* Get pan vector
*
* @return {object} {x: 0, y: 0}
*/
getPan(): IPoint;
zoomAtPoint(scale:number, point:IPoint): boolean;
zoomAtPointBy(scale:number, point:IPoint): boolean;
}
}
declare var svgPanZoom:SvgPanZoom.ISvgPanZoom;