@@ -18,11 +18,9 @@ export function useConstrainedFloatingButton(
1818
1919 if ( isExpanded ) {
2020 if ( buttonElement ) {
21- buttonElement . style . position = 'fixed'
2221 buttonElement . style . left = `${ offset } px`
23- buttonElement . style . bottom = `${ offset } px`
22+ buttonElement . style . bottom = `${ 3 * offset + offset } px`
2423 buttonElement . style . top = ''
25- buttonElement . style . zIndex = '2000'
2624 buttonElement . style . display = ''
2725 }
2826 return
@@ -71,9 +69,7 @@ export function useConstrainedFloatingButton(
7169 }
7270
7371 if ( buttonElement ) {
74- buttonElement . style . position = 'fixed'
7572 buttonElement . style . left = `${ mapRect . left + offset } px`
76- buttonElement . style . zIndex = '2000'
7773 if ( finalTop !== undefined ) {
7874 buttonElement . style . top = `${ finalTop } px`
7975 buttonElement . style . bottom = ''
@@ -100,17 +96,20 @@ export function useConstrainedFloatingButton(
10096 intersectionObserver . observe ( mapContainerRef . current )
10197 }
10298
103- window . addEventListener ( 'scroll' , updateButtonPosition , { passive : true } )
99+ window . document
100+ . getElementsByClassName ( 'ant-layout-content' )
101+ . item ( 0 )
102+ ?. addEventListener ( 'scroll' , updateButtonPosition )
104103 window . addEventListener ( 'resize' , updateButtonPosition )
105104
106- const intervalId = setInterval ( updateButtonPosition , 200 )
107-
108105 return ( ) => {
109- clearInterval ( intervalId )
110106 if ( intersectionObserver ) {
111107 intersectionObserver . disconnect ( )
112108 }
113- window . removeEventListener ( 'scroll' , updateButtonPosition )
109+ window . document
110+ . getElementsByClassName ( 'ant-layout-content' )
111+ . item ( 0 )
112+ ?. removeEventListener ( 'scroll' , updateButtonPosition )
114113 window . removeEventListener ( 'resize' , updateButtonPosition )
115114 }
116115 } , [ mapContainerRef , buttonRef , isExpanded ] )
0 commit comments