@@ -16,26 +16,31 @@ export function useHoverInteractions(
1616
1717 const onMouseEnter = useCallback (
1818 ( index : number ) => {
19- const { getNodeByIndex, childCount } = ref . current
20- let containerStyles = containerRef ?. current ?. style ;
21- if ( index < childCount && containerStyles ) {
22- let node = getNodeByIndex ( index )
23- if ( ! node ) return ;
24- let parentIndex = node . childCount > 1
25- ? node . parentIndex . at ( - 1 )
26- : node . parentIndex . at ( - 2 )
27- ?? 0
28- // console.log({ parentIndex })
29- containerStyles . setProperty ( '--active-index' , String ( index ) ) ;
30- containerStyles . setProperty ( '--active-parent' , String ( parentIndex ) ) ;
31- }
19+
20+ clearTimeout ( ref . current . timeout ) ;
21+
22+ ref . current . timeout = setTimeout ( ( ) => {
23+
24+ const { getNodeByIndex, childCount } = ref . current
25+ let containerStyles = containerRef ?. current ?. style ;
26+ if ( index < childCount && containerStyles ) {
27+ let node = getNodeByIndex ( index )
28+ if ( ! node ) return ;
29+ let parentIndex = node . childCount > 1
30+ ? node . parentIndex . at ( - 1 )
31+ : node . parentIndex . at ( - 2 )
32+ ?? 0
33+ containerStyles . setProperty ( '--active-index' , String ( index ) ) ;
34+ containerStyles . setProperty ( '--active-parent' , String ( parentIndex ) ) ;
35+ }
36+ } , 50 ) ;
37+
3238 } ,
3339 [ containerRef , ref ]
3440 ) ;
3541
3642 const onMouseLeave = useCallback (
3743 ( index : number ) => {
38-
3944 clearTimeout ( ref . current . timeout ) ;
4045
4146 ref . current . timeout = setTimeout ( ( ) => {
@@ -51,7 +56,7 @@ export function useHoverInteractions(
5156 }
5257
5358 }
54- } , 25 ) ;
59+ } , 100 ) ;
5560 } ,
5661 [ containerRef , ref ]
5762 ) ;
0 commit comments