mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-30 15:37:36 +01:00
Merge pull request #5703 from Krausus/HoldStillASecond
Fixes Goonchat Scrolling When Pruning Old Messages
This commit is contained in:
@@ -215,13 +215,7 @@ function output(message, flag) {
|
||||
message = linkify(message);
|
||||
}
|
||||
|
||||
opts.messageCount++;
|
||||
|
||||
//Pop the top message off if history limit reached
|
||||
if (opts.messageCount >= opts.messageLimit) {
|
||||
$messages.children('div.entry:first-child').remove();
|
||||
opts.messageCount--; //I guess the count should only ever equal the limit
|
||||
}
|
||||
opts.messageCount++;
|
||||
|
||||
//Actually append the message
|
||||
var entry = document.createElement('div');
|
||||
@@ -463,6 +457,20 @@ $(function() {
|
||||
$('.connectionClosed[data-count="'+opts.noResponseCount+'"]:not(.restored)').addClass('restored').text('Your connection has been restored (probably)!');
|
||||
opts.noResponse = false;
|
||||
}
|
||||
if (opts.messageCount > opts.messageLimit) { // Prune old messages beyond the message limit
|
||||
var bodyHeight = $('body').height();
|
||||
var messagesHeight = $messages.outerHeight();
|
||||
var scrollPos = $(window).scrollTop();
|
||||
var atBottom = (bodyHeight + scrollPos >= messagesHeight - opts.scrollSnapTolerance)
|
||||
|
||||
$messages.children().slice(0, opts.messageCount - opts.messageLimit).remove();
|
||||
opts.messageCount = opts.messageLimit;
|
||||
if (!atBottom) {
|
||||
// If we weren't at the bottom, adjust scroll position to compensate for removed elements
|
||||
var newPos = scrollPos - (messagesHeight - $messages.outerHeight())
|
||||
$('body,html').scrollTop(newPos);
|
||||
}
|
||||
}
|
||||
}, 2000); //2 seconds
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user