@@ -26,6 +26,8 @@ export interface TooltipProviderOptions {
26
26
crossAxis ?: number
27
27
alignmentAxis ?: number | null
28
28
}
29
+ // The amount to shift the block by. Default is 0.
30
+ shift ?: number
29
31
/// Other middlewares for floating ui. This will be added after the internal middlewares.
30
32
middleware ?: Middleware [ ]
31
33
/// Options for floating ui. If you pass `middleware` or `placement`, it will override the internal settings.
@@ -62,7 +64,8 @@ export class TooltipProvider {
62
64
crossAxis ?: number
63
65
alignmentAxis ?: number | null
64
66
}
65
-
67
+ /// @internal
68
+ readonly #shift?: number
66
69
/// The root element of the tooltip.
67
70
element : HTMLElement
68
71
@@ -77,6 +80,7 @@ export class TooltipProvider {
77
80
this . #debounce = options . debounce ?? 200
78
81
this . #shouldShow = options . shouldShow ?? this . #_shouldShow
79
82
this . #offset = options . offset
83
+ this . #shift = options . shift
80
84
this . #middleware = options . middleware ?? [ ]
81
85
this . #floatingUIOptions = options . floatingUIOptions ?? { }
82
86
this . #root = options . root
@@ -111,7 +115,7 @@ export class TooltipProvider {
111
115
}
112
116
computePosition ( virtualEl , this . element , {
113
117
placement : this . #floatingUIOptions. placement ?? 'top' ,
114
- middleware : [ flip ( ) , offset ( this . #offset) , shift ( ) , ...this . #middleware] ,
118
+ middleware : [ flip ( ) , offset ( this . #offset) , shift ( this . #shift ) , ...this . #middleware] ,
115
119
} ) . then ( ( { x, y } ) => {
116
120
Object . assign ( this . element . style , {
117
121
left : `${ x } px` ,
@@ -159,7 +163,7 @@ export class TooltipProvider {
159
163
if ( virtualElement ) {
160
164
computePosition ( virtualElement , this . element , {
161
165
placement : 'top' ,
162
- middleware : [ flip ( ) , offset ( this . #offset) , shift ( ) ] ,
166
+ middleware : [ flip ( ) , offset ( this . #offset) , shift ( this . #offset ) ] ,
163
167
...this . #floatingUIOptions,
164
168
} ) . then ( ( { x, y } ) => {
165
169
Object . assign ( this . element . style , {
0 commit comments