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>
4444| :----------- | :------------------------------------------------------------------ | :---------------------------------------------- |
4545| action | The action that triggers the tooltip (hover | click | prop) | ` string ` (default: ` hover ` ) |
4646| 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 ` ) |
4748| arrow | If ` false ` , the tooltip arrow will not be shown. | ` boolean ` (default: ` true ` ) |
4849| autoPosition | Adjust tooltip position if viewport clipping occurs | ` string ` (default: ` false ` ) |
4950| content | The string or object containing componentref and props | ` string ` | ` object ` component (default: ``) |
Original file line number Diff line number Diff line change 3232 /** @type {string} */
3333 export let animation = ' ' ;
3434
35+ /** @type {number} */
36+ export let delay = 200 ;
37+
3538 /** @type {boolean} */
3639 export let arrow = true ;
3740
6467 left: 0
6568 };
6669
67- const delay = animation ? 200 : 0 ;
70+ const animationDelay = animation ? delay : 0 ;
6871
6972 onMount (() => {
7073 if (tooltipRef !== null ) {
97100 animationEffect = animation;
98101 }
99102
100- setTimeout (() => (visible = true ), delay );
103+ setTimeout (() => (visible = true ), animationDelay );
101104 });
102105
103106 onDestroy (() => {
108111 });
109112
110113 $: isComponent = typeof content === ' object' ;
111- $: tooltipRef && show ? setTimeout (() => (visible = true ), delay ) : (visible = false );
114+ $: tooltipRef && show ? setTimeout (() => (visible = true ), animationDelay ) : (visible = false );
112115 </script >
113116
114117{#if content }
Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ export interface ComponentProps {
1919 */
2020 animation ?: string ;
2121
22+ /**
23+ * The animation's delay of the tooltip.
24+ * @default 200
25+ */
26+ delay ?: number ;
27+
2228 /**
2329 * Whether to show the arrow of the tooltip.
2430 * @default true
Original file line number Diff line number Diff line change 2929 /** @type {string} */
3030 export let animation = ' ' ;
3131
32+ /** @type {number} */
33+ export let delay = 200 ;
34+
3235 /** @type {boolean} */
3336 export let arrow = true ;
3437
7982 };
8083
8184 const onShow = () => {
82- const delay = animation ? 200 : 0 ;
85+ const animationDelay = animation ? delay : 0 ;
8386
8487 // @ts-ignore
8588 if (autoPosition && ! isElementInViewport (containerRef, tooltipRef, position)) {
9396 animationEffect = animation;
9497 }
9598
96- timer = setTimeout (() => (visible = true ), delay );
99+ timer = setTimeout (() => (visible = true ), animationDelay );
97100 };
98101
99102 const onHide = () => {
Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ export interface ComponentProps {
1919 */
2020 animation ?: string ;
2121
22+ /**
23+ * The animation's delay of the tooltip.
24+ * @default 200
25+ */
26+ delay ?: number ;
27+
2228 /**
2329 * Whether to show the arrow of the tooltip.
2430 * @default true
You can’t perform that action at this time.
0 commit comments