-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.d.ts
163 lines (163 loc) · 4.29 KB
/
index.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
152
153
154
155
156
157
158
159
160
161
162
163
export type ICursorType = "normal" | "text" | "block";
/**
* if without unit, `px` is used by default
*/
type MaybeSize = string | number;
/** if without unit `ms` is used by default */
type MaybeDuration = string | number;
/** do not use 0x000000, use #000000 instead */
type MaybeColor = string;
/**
* Configurations for the cursor
*/
export interface IpadCursorConfig {
/**
* Strength of adsorption, the larger the value,
* The higher the value, the greater the range of the block that can be moved when it is hovered
* @type {number} between 0 and 30
* @default 10
*/
adsorptionStrength?: number;
/**
* The class name of the cursor element
* @type {string}
* @default 'cursor'
*/
className?: string;
/**
* The style of the cursor, when it does not hover on any element
*/
normalStyle?: IpadCursorStyle;
/**
* The style of the cursor, when it hovers on text
*/
textStyle?: IpadCursorStyle;
/**
* The style of the cursor, when it hovers on a block
*/
blockStyle?: IpadCursorStyle;
/**
* The style of the cursor, when mousedown
*/
mouseDownStyle?: IpadCursorStyle;
/**
* Cursor padding when hover on block
*/
blockPadding?: number | "auto";
/**
* detect text node and apply text cursor automatically
**/
enableAutoTextCursor?: boolean;
/**
* enable detect dom change and auto call updateCursor
**/
enableAutoUpdateCursor?: boolean;
/**
* whether to enable lighting effect
*/
enableLighting?: boolean;
/**
* whether to apply effect for mousedown action
*/
enableMouseDownEffect?: boolean;
}
/**
* Configurable style of the cursor (Experimental)
* This feature is Experimental, so it's set to false by default.
* And it not support `block` yet
*/
export interface IpadCursorStyle {
/**
* The width of the cursor
*/
width?: MaybeSize;
/**
* The width of the cursor
*/
height?: MaybeSize;
/**
* Border radius of cursor
*/
radius?: MaybeSize | "auto";
/**
* Transition duration of basic properties like width, height, radius, border, background-color
*/
durationBase?: MaybeDuration;
/**
* Transition duration of position: left, top
*/
durationPosition?: MaybeDuration;
/**
* Transition duration of backdrop-filter
*/
durationBackdropFilter?: MaybeDuration;
/**
* The background color of the cursor
*/
background?: MaybeColor;
/**
* Border of the cursor
* @example '1px solid rgba(100, 100, 100, 0.1)'
*/
border?: string;
/** z-index of cursor */
zIndex?: number;
/**
* Scale of cursor
*/
scale?: number;
/**
* backdrop-filter blur
*/
backdropBlur?: MaybeSize;
/**
* backdrop-filter saturate
*/
backdropSaturate?: string;
}
/**
* Init cursor, hide default cursor, and listen mousemove event
* will only run once in client even if called multiple times
* @returns
*/
declare function initCursor(_config?: IpadCursorConfig): void;
/**
* destroy cursor, remove event listener and remove cursor element
* @returns
*/
declare function disposeCursor(): void;
/**
* Update current Configuration
* @param _config
*/
declare function updateConfig(_config: IpadCursorConfig): IpadCursorConfig;
/**
* Detect all interactive elements in the page
* Update the binding of events, remove listeners for elements that are removed
* @returns
*/
declare function updateCursor(): void;
/**
* Create custom style that can be bound to `data-cursor-style`
* @param style
*/
declare function customCursorStyle(style: IpadCursorStyle & Record<string, any>): string;
declare function resetCursor(): void;
declare const CursorType: {
TEXT: ICursorType;
BLOCK: ICursorType;
};
declare const exported: {
CursorType: {
TEXT: ICursorType;
BLOCK: ICursorType;
};
resetCursor: typeof resetCursor;
initCursor: typeof initCursor;
updateCursor: typeof updateCursor;
disposeCursor: typeof disposeCursor;
updateConfig: typeof updateConfig;
customCursorStyle: typeof customCursorStyle;
};
export { CursorType, resetCursor, initCursor, updateCursor, disposeCursor, updateConfig, customCursorStyle, };
export default exported;