Changeset View
Changeset View
Standalone View
Standalone View
native/chat/reaction-message-utils.js
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | function useReactionSelectionPopoverPosition({ | ||||
const popoverLocation: 'above' | 'below' = (() => { | const popoverLocation: 'above' | 'below' = (() => { | ||||
const { y, height } = initialCoordinates; | const { y, height } = initialCoordinates; | ||||
const contentTop = y; | const contentTop = y; | ||||
const contentBottom = y + height; | const contentBottom = y + height; | ||||
const boundsTop = verticalBounds.y; | const boundsTop = verticalBounds.y; | ||||
const boundsBottom = verticalBounds.y + verticalBounds.height; | const boundsBottom = verticalBounds.y + verticalBounds.height; | ||||
const fullHeight = reactionSelectionPopoverHeight + calculatedMargin; | const fullHeight = | ||||
reactionSelectionPopoverDimensions.height + calculatedMargin; | |||||
if ( | if ( | ||||
contentBottom + fullHeight > boundsBottom && | contentBottom + fullHeight > boundsBottom && | ||||
contentTop - fullHeight > boundsTop | contentTop - fullHeight > boundsTop | ||||
) { | ) { | ||||
return 'above'; | return 'above'; | ||||
} | } | ||||
Show All 31 Lines | return React.useMemo( | ||||
[popoverLocation, containerStyle], | [popoverLocation, containerStyle], | ||||
); | ); | ||||
} | } | ||||
function getCalculatedMargin(margin: ?number): number { | function getCalculatedMargin(margin: ?number): number { | ||||
return margin ?? 16; | return margin ?? 16; | ||||
} | } | ||||
const reactionSelectionPopoverHeight = 56; | const reactionSelectionPopoverDimensions = { | ||||
height: 56, | |||||
width: 316, | |||||
}; | |||||
export { | export { | ||||
useSendReaction, | useSendReaction, | ||||
useReactionSelectionPopoverPosition, | useReactionSelectionPopoverPosition, | ||||
getCalculatedMargin, | getCalculatedMargin, | ||||
reactionSelectionPopoverHeight, | reactionSelectionPopoverDimensions, | ||||
}; | }; |