Chatwoot/app/javascript/dashboard/components/widgets/conversation/helpers/scrollTopCalculationHelper.js

19 lines
443 B
JavaScript
Raw Normal View History

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
);
};