File tree Expand file tree Collapse file tree 5 files changed +24
-5
lines changed Expand file tree Collapse file tree 5 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ Checkout out my <u use:tooltip={{ content: 'Hello World!' }}>tooltip</u>
44
44
| :----------- | :------------------------------------------------------------------ | :---------------------------------------------- |
45
45
| action | The action that triggers the tooltip (hover | click | prop) | ` string ` (default: ` hover ` ) |
46
46
| animation | The animation to apply to the tooltip | ` string ` (default: ``) |
47
+ | delay | The animation delay in milliseconds to apply to the tooltip | ` number ` (default: ` 200 ` ) |
47
48
| arrow | If ` false ` , the tooltip arrow will not be shown. | ` boolean ` (default: ` true ` ) |
48
49
| autoPosition | Adjust tooltip position if viewport clipping occurs | ` string ` (default: ` false ` ) |
49
50
| content | The string or object containing componentref and props | ` string ` | ` object ` component (default: ``) |
Original file line number Diff line number Diff line change 32
32
/** @type {string} */
33
33
export let animation = ' ' ;
34
34
35
+ /** @type {number} */
36
+ export let delay = 200 ;
37
+
35
38
/** @type {boolean} */
36
39
export let arrow = true ;
37
40
64
67
left: 0
65
68
};
66
69
67
- const delay = animation ? 200 : 0 ;
70
+ const animationDelay = animation ? delay : 0 ;
68
71
69
72
onMount (() => {
70
73
if (tooltipRef !== null ) {
97
100
animationEffect = animation;
98
101
}
99
102
100
- setTimeout (() => (visible = true ), delay );
103
+ setTimeout (() => (visible = true ), animationDelay );
101
104
});
102
105
103
106
onDestroy (() => {
108
111
});
109
112
110
113
$: isComponent = typeof content === ' object' ;
111
- $: tooltipRef && show ? setTimeout (() => (visible = true ), delay ) : (visible = false );
114
+ $: tooltipRef && show ? setTimeout (() => (visible = true ), animationDelay ) : (visible = false );
112
115
</script >
113
116
114
117
{#if content }
Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ export interface ComponentProps {
19
19
*/
20
20
animation ?: string ;
21
21
22
+ /**
23
+ * The animation's delay of the tooltip.
24
+ * @default 200
25
+ */
26
+ delay ?: number ;
27
+
22
28
/**
23
29
* Whether to show the arrow of the tooltip.
24
30
* @default true
Original file line number Diff line number Diff line change 29
29
/** @type {string} */
30
30
export let animation = ' ' ;
31
31
32
+ /** @type {number} */
33
+ export let delay = 200 ;
34
+
32
35
/** @type {boolean} */
33
36
export let arrow = true ;
34
37
79
82
};
80
83
81
84
const onShow = () => {
82
- const delay = animation ? 200 : 0 ;
85
+ const animationDelay = animation ? delay : 0 ;
83
86
84
87
// @ts-ignore
85
88
if (autoPosition && ! isElementInViewport (containerRef, tooltipRef, position)) {
93
96
animationEffect = animation;
94
97
}
95
98
96
- timer = setTimeout (() => (visible = true ), delay );
99
+ timer = setTimeout (() => (visible = true ), animationDelay );
97
100
};
98
101
99
102
const onHide = () => {
Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ export interface ComponentProps {
19
19
*/
20
20
animation ?: string ;
21
21
22
+ /**
23
+ * The animation's delay of the tooltip.
24
+ * @default 200
25
+ */
26
+ delay ?: number ;
27
+
22
28
/**
23
29
* Whether to show the arrow of the tooltip.
24
30
* @default true
You can’t perform that action at this time.
0 commit comments