@@ -21,6 +21,8 @@ const tooltipStyle = {
21
21
left : 0 ,
22
22
}
23
23
24
+ const translate = ( x , y ) => `translate(${ x } px, ${ y } px)`
25
+
24
26
const TooltipWrapper = ( { position, anchor, children } ) => {
25
27
const theme = useTheme ( )
26
28
const { animate, config : springConfig } = useMotionConfig ( )
@@ -29,12 +31,12 @@ const TooltipWrapper = ({ position, anchor, children }) => {
29
31
30
32
let to = undefined
31
33
let immediate = false
32
-
33
34
const hasDimension = bounds . width > 0 && bounds . height > 0
34
- if ( hasDimension ) {
35
- let x = Math . round ( position [ 0 ] )
36
- let y = Math . round ( position [ 1 ] )
37
35
36
+ let x = Math . round ( position [ 0 ] )
37
+ let y = Math . round ( position [ 1 ] )
38
+
39
+ if ( hasDimension ) {
38
40
if ( anchor === 'top' ) {
39
41
x -= bounds . width / 2
40
42
y -= bounds . height + TOOLTIP_OFFSET
@@ -53,7 +55,7 @@ const TooltipWrapper = ({ position, anchor, children }) => {
53
55
}
54
56
55
57
to = {
56
- transform : ` translate(${ x } px, ${ y } px)` ,
58
+ transform : translate ( x , y ) ,
57
59
}
58
60
if ( ! previousPosition . current ) {
59
61
immediate = true
@@ -71,8 +73,7 @@ const TooltipWrapper = ({ position, anchor, children }) => {
71
73
const style = {
72
74
...tooltipStyle ,
73
75
...theme . tooltip ,
74
- transform : animatedProps . transform ,
75
- opacity : animatedProps . transform ? 1 : 0 ,
76
+ transform : animatedProps . transform ?? translate ( x , y ) ,
76
77
}
77
78
78
79
return (
0 commit comments