19 lines
443 B
JavaScript
19 lines
443 B
JavaScript
|
const totalMessageHeight = (total, element) => {
|
||
|
return total + element.scrollHeight;
|
||
|
};
|
||
|
|
||
|
export const calculateScrollTop = (
|
||
|
conversationPanelHeight,
|
||
|
parentHeight,
|
||
|
relevantMessages
|
||
|
) => {
|
||
|
// add up scrollHeight of a `relevantMessages`
|
||
|
let combinedMessageScrollHeight = [...relevantMessages].reduce(
|
||
|
totalMessageHeight,
|
||
|
0
|
||
|
);
|
||
|
return (
|
||
|
conversationPanelHeight - combinedMessageScrollHeight - parentHeight / 2
|
||
|
);
|
||
|
};
|