Skip to content

Commit

Permalink
Fixed removal of OOB messages for horizontal scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
izzy committed Apr 18, 2022
1 parent 07418c5 commit d7cdfd7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@
}

let bubbles = url.searchParams.get("bubbles");
let direction = url.searchParams.get("direction");

direction = 'vertical';
if (url.searchParams.get("direction") !== null) {
direction = url.searchParams.get("direction").toLowerCase() === 'horizontal' ? 'horizontal' : 'vertical';
}

if (is_true(bubbles)) {
console.log('Enabled bubble display');
Expand Down Expand Up @@ -258,6 +262,7 @@
}

return {
'direction': direction,
'background_color': background_color,
'text_color': text_color,
'default_color': default_color,
Expand Down Expand Up @@ -481,7 +486,11 @@
for (let i = 0; i < messages.length; i++) {

// Remove messages that are outside the bounding box
if (messages[i].getBoundingClientRect().top < 0) {
// bottom when vertical scrolling is enabled,
// right when horizontal scrolling is enabled
if ((config['direction'] === 'vertical' && messages[i].getBoundingClientRect().bottom < 0) ||
(config['direction'] === 'horizontal' && messages[i].getBoundingClientRect().right < 0)
) {
messages_to_remove.push(messages[i]);
}
// Remove messages that are older than the max age (fade_duration)
Expand Down

0 comments on commit d7cdfd7

Please sign in to comment.