@@ -12,11 +12,13 @@ export default function useListPosition(
1212) {
1313 const [ sizeMap , setNodeSize ] = useSizes ( ) ;
1414
15- const [ notificationPosition , totalHeight ] = React . useMemo ( ( ) => {
15+ const [ notificationPosition , totalHeight , topNoticeHeight , topNoticeWidth ] = React . useMemo ( ( ) => {
1616 let offsetY = 0 ;
1717 let nextTotalHeight = 0 ;
1818 const stackThreshold = stack ?. threshold ?? 0 ;
1919 const nextNotificationPosition = new Map < string , number > ( ) ;
20+ let nextTopNoticeHeight : number | undefined ;
21+ let nextTopNoticeWidth : number | undefined ;
2022
2123 configList
2224 . slice ( )
@@ -29,6 +31,11 @@ export default function useListPosition(
2931
3032 nextNotificationPosition . set ( key , y ) ;
3133
34+ if ( index === 0 ) {
35+ nextTopNoticeHeight = height ;
36+ nextTopNoticeWidth = sizeMap [ key ] ?. width ?? 0 ;
37+ }
38+
3239 if ( ! stack || index < stackThreshold ) {
3340 nextTotalHeight = Math . max ( nextTotalHeight , y + height ) ;
3441 }
@@ -40,8 +47,13 @@ export default function useListPosition(
4047 }
4148 } ) ;
4249
43- return [ nextNotificationPosition , nextTotalHeight ] as const ;
50+ return [
51+ nextNotificationPosition ,
52+ nextTotalHeight ,
53+ nextTopNoticeHeight ,
54+ nextTopNoticeWidth ,
55+ ] as const ;
4456 } , [ configList , gap , sizeMap , stack ] ) ;
4557
46- return [ notificationPosition , setNodeSize , totalHeight ] as const ;
58+ return [ notificationPosition , setNodeSize , totalHeight , topNoticeHeight , topNoticeWidth ] as const ;
4759}
0 commit comments