@@ -125,9 +125,10 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
125125 const msgH = messageH . value . h ;
126126 const minTop = minY + topH . value . h ;
127127 const maxTopWithBottom = maxY - ( msgH + bottomH . value . h ) ;
128- const maxTopWithoutBottom = maxY - msgH ;
129- const maxTop = minTop <= maxTopWithBottom ? maxTopWithBottom : maxTopWithoutBottom ;
130- const solvedTop = clamp ( anchorY , minTop , Math . max ( minTop , maxTop ) ) ;
128+ const canFitBottomWithoutOverlap = minTop <= maxTopWithBottom ;
129+ const solvedTop = canFitBottomWithoutOverlap
130+ ? clamp ( anchorY , minTop , Math . max ( minTop , maxTopWithBottom ) )
131+ : minTop ;
131132
132133 return solvedTop - anchorY ;
133134 } ) ;
@@ -139,16 +140,10 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
139140 const msgH = messageH . value . h ;
140141 const minMessageTop = minY + topH . value . h ;
141142 const maxMessageTopWithBottom = maxY - ( msgH + bottomH . value . h ) ;
142- const maxMessageTopWithoutBottom = maxY - msgH ;
143- const maxMessageTop =
144- minMessageTop <= maxMessageTopWithBottom
145- ? maxMessageTopWithBottom
146- : maxMessageTopWithoutBottom ;
147- const solvedMessageTop = clamp (
148- anchorMessageTop ,
149- minMessageTop ,
150- Math . max ( minMessageTop , maxMessageTop ) ,
151- ) ;
143+ const canFitBottomWithoutOverlap = minMessageTop <= maxMessageTopWithBottom ;
144+ const solvedMessageTop = canFitBottomWithoutOverlap
145+ ? clamp ( anchorMessageTop , minMessageTop , Math . max ( minMessageTop , maxMessageTopWithBottom ) )
146+ : minMessageTop ;
152147
153148 const solvedBottomTop = Math . min ( solvedMessageTop + msgH , maxY - bottomH . value . h ) ;
154149 return solvedBottomTop - bottomH . value . y ;
0 commit comments