@@ -14,7 +14,11 @@ import { throttle } from './../../util/throttle';
14
14
import { lerp } from ' ./../../util/math' ;
15
15
import { generateCSSTransform } from ' ./../../util/dom' ;
16
16
import { hoverState } from ' ./../../directives/hover' ;
17
- import { TransformProps , HoverBehavior } from ' ./../../common/types' ;
17
+ import {
18
+ TransformProps ,
19
+ HoverBehavior ,
20
+ TetikusProps ,
21
+ } from ' ./../../common/types' ;
18
22
import {
19
23
defaultTransitionSpeed ,
20
24
defaultEasingFunction ,
@@ -79,8 +83,10 @@ export default defineComponent({
79
83
buttonMap: {
80
84
type: Array ,
81
85
default : () => [' left' ],
82
- validator : (val : Array <string >) => {
83
- return val .every ((v ) => [' left' , ' middle' , ' right' ].includes (v ));
86
+ validator : (values : string []) => {
87
+ return values .every (
88
+ (value : string ) => [' left' , ' middle' , ' right' ].includes (value ),
89
+ );
84
90
},
85
91
},
86
92
@@ -145,9 +151,20 @@ export default defineComponent({
145
151
type: Number ,
146
152
default: defaultDelay .value ,
147
153
},
154
+
155
+ // Unified tetikus props
156
+ // Useful to avoid apropcalypse
157
+ options: {
158
+ type: Object as () => TetikusProps ,
159
+ default: {},
160
+ },
148
161
},
149
162
150
- setup(props , { slots , emit }) {
163
+ setup(properties , { slots , emit }) {
164
+ // construct new props unified object from options
165
+ // any undefined values will fallback normally.
166
+ const props = { ... properties , ... properties .options };
167
+
151
168
// wrapper element ref
152
169
const wrapper: Ref <HTMLElement | null > = ref (null );
153
170
// cursor element ref
@@ -164,7 +181,7 @@ export default defineComponent({
164
181
165
182
// css styles for cursor wrapper element
166
183
const wrapperStyle = computed (() => {
167
- const baseStyles: Record <string , unknown > = {
184
+ const baseStyles: Record <string , string | number > = {
168
185
' opacity' : props .opacity ,
169
186
' mix-blend-mode' : props .invertColor ? ' difference' : ' normal' ,
170
187
' flex-direction' : props .contentPosition === ' bottom' ?
@@ -199,7 +216,8 @@ export default defineComponent({
199
216
const contentStyle = computed (() => {
200
217
return {
201
218
' position' : props .contentPosition === ' center' ?
202
- ' absolute' : ' center' ,
219
+ ' absolute' :
220
+ ' center' ,
203
221
};
204
222
});
205
223
@@ -309,7 +327,9 @@ export default defineComponent({
309
327
310
328
// apply transformation on mouse button press
311
329
const handleMouseDown = (event : MouseEvent ): void => {
312
- if (! props .buttonMap .includes (buttonMap .get (event .button ))) {
330
+ const button = buttonMap .get (event .button ) as string ;
331
+
332
+ if (! props .buttonMap .includes (button )) {
313
333
return ;
314
334
}
315
335
@@ -334,7 +354,9 @@ export default defineComponent({
334
354
335
355
// apply another transform on cursor when mouse button is lifted
336
356
const handleMouseUp = (event : MouseEvent ): void => {
337
- if (! props .buttonMap .includes (buttonMap .get (event .button ))) {
357
+ const button = buttonMap .get (event .button ) as string ;
358
+
359
+ if (! props .buttonMap .includes (button )) {
338
360
return ;
339
361
}
340
362
@@ -384,6 +406,8 @@ export default defineComponent({
384
406
... defaultTransformStyle .value ,
385
407
... transformProps ,
386
408
};
409
+ // prevent TetikusWarning error
410
+ delete transformTarget .id ;
387
411
388
412
applyTransform (defaultTransformStyle .value , transformTarget , false );
389
413
}
0 commit comments