mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
dynamic hiding of offscreen chat messages
This commit is contained in:
@ -851,7 +851,7 @@ async function printCharacters() {
|
||||
sortCharactersList();
|
||||
favsToHotswap();
|
||||
await delay(300);
|
||||
updateVisibleDivs();
|
||||
updateVisibleDivs('#rm_print_characters_block', true);
|
||||
|
||||
}
|
||||
|
||||
@ -4521,7 +4521,7 @@ function select_rm_characters() {
|
||||
menu_type = "characters";
|
||||
selectRightMenuWithAnimation('rm_characters_block');
|
||||
setRightTabSelectedClass('rm_button_characters');
|
||||
updateVisibleDivs();
|
||||
updateVisibleDivs('#rm_print_characters_block', true);
|
||||
}
|
||||
|
||||
function setExtensionPrompt(key, value, position, depth) {
|
||||
@ -5403,21 +5403,19 @@ const swipe_right = () => {
|
||||
}
|
||||
}
|
||||
|
||||
function updateVisibleDivs() {
|
||||
|
||||
var $container = $('#rm_print_characters_block');
|
||||
function updateVisibleDivs(containerSelector, resizecontainer) {
|
||||
var $container = $(containerSelector);
|
||||
var $children = $container.children();
|
||||
var totalHeight = 0;
|
||||
$children.each(function () {
|
||||
totalHeight += $(this).outerHeight();
|
||||
});
|
||||
if (resizecontainer) {
|
||||
$container.css({
|
||||
height: totalHeight,
|
||||
});
|
||||
//var scrollTop = $container.scrollTop();
|
||||
var containerTop = $container.offset().top;
|
||||
//var containerBottom = containerTop + $container.height();
|
||||
//console.log(`${scrollTop},${containerTop},${containerBottom}`);
|
||||
}
|
||||
var containerTop = $container.offset() ? $container.offset().top : 0;
|
||||
var firstVisibleIndex = null;
|
||||
var lastVisibleIndex = null;
|
||||
$children.each(function (index) {
|
||||
@ -5430,11 +5428,8 @@ function updateVisibleDivs() {
|
||||
}
|
||||
lastVisibleIndex = index;
|
||||
}
|
||||
$child.toggleClass('hiddenByCharListScroll', childTop > $container.height() || childBottom < 0);
|
||||
$child.toggleClass('hiddenByScroll', childTop > $container.height() || childBottom < 0);
|
||||
});
|
||||
//var visibleStart = firstVisibleIndex !== null ? firstVisibleIndex : 0;
|
||||
//var visibleEnd = lastVisibleIndex !== null ? lastVisibleIndex + 1 : 0;
|
||||
//console.log(`${visibleStart},${visibleEnd}`);
|
||||
}
|
||||
|
||||
|
||||
@ -5500,8 +5495,13 @@ $(document).ready(function () {
|
||||
}, 200);
|
||||
|
||||
|
||||
$("#rm_print_characters_block").on('scroll',
|
||||
debounce(updateVisibleDivs, 5));
|
||||
$("#rm_print_characters_block").on('scroll', debounce(() => {
|
||||
updateVisibleDivs('#rm_print_characters_block', true);
|
||||
}, 5));
|
||||
|
||||
$("#chat").on('scroll', debounce(() => {
|
||||
updateVisibleDivs('#chat', false);
|
||||
}, 5));
|
||||
|
||||
let S_TAFocused = false;
|
||||
let S_TAPreviouslyFocused = false;
|
||||
@ -5553,7 +5553,7 @@ $(document).ready(function () {
|
||||
|
||||
if (!searchValue) {
|
||||
$(selector).removeClass('hiddenBySearch');
|
||||
updateVisibleDivs();
|
||||
updateVisibleDivs('#rm_print_characters_block', false);
|
||||
} else {
|
||||
$(selector).each(function () {
|
||||
const isValidSearch = $(this)
|
||||
@ -5564,7 +5564,7 @@ $(document).ready(function () {
|
||||
|
||||
$(this).toggleClass('hiddenBySearch', !isValidSearch);
|
||||
});
|
||||
updateVisibleDivs();
|
||||
updateVisibleDivs('#rm_print_characters_block', false);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -82,7 +82,7 @@ function addQuickReplyBar(numButtons) {
|
||||
for (let i = 0; i < numButtons; i++) {
|
||||
let quickReplyMes = extension_settings.quickReply[`quickReply${i + 1}Mes`];
|
||||
let quickReplyLabel = extension_settings.quickReply[`quickReply${i + 1}Label`];
|
||||
console.log(quickReplyMes);
|
||||
//console.log(quickReplyMes);
|
||||
quickReplyButtonHtml += `<div title="${quickReplyMes}" class="quickReplyButton" id="quickReply${i + 1}">${quickReplyLabel}</div>`;
|
||||
}
|
||||
const quickReplyEndHtml = `</div></div>`
|
||||
|
@ -729,7 +729,7 @@ function sortCharactersList() {
|
||||
for (const item of array) {
|
||||
$(`${item.selector}[${item.attribute}="${item.id}"]`).css({ 'order': orderedList.indexOf(item) });
|
||||
}
|
||||
updateVisibleDivs();
|
||||
updateVisibleDivs('#rm_print_characters_block', true);
|
||||
}
|
||||
|
||||
function sortGroupMembers(selector) {
|
||||
|
@ -59,7 +59,7 @@ function applyFavFilter() {
|
||||
}
|
||||
|
||||
});
|
||||
updateVisibleDivs();
|
||||
updateVisibleDivs('#rm_print_characters_block', true);
|
||||
}
|
||||
|
||||
function filterByGroups() {
|
||||
@ -71,7 +71,7 @@ function filterByGroups() {
|
||||
$(CHARACTER_SELECTOR).each((_, element) => {
|
||||
$(element).toggleClass('hiddenByGroup', displayGroupsOnly && !$(element).hasClass('group_select'));
|
||||
});
|
||||
updateVisibleDivs();
|
||||
updateVisibleDivs('#rm_print_characters_block', true);
|
||||
}
|
||||
|
||||
function loadTagsSettings(settings) {
|
||||
@ -245,7 +245,7 @@ function onTagFilterClick(listElement) {
|
||||
|
||||
const tagIds = [...($(listElement).find(".tag.selected:not(.actionable)").map((_, el) => $(el).attr("id")))];
|
||||
$(CHARACTER_SELECTOR).each((_, element) => applyFilterToElement(tagIds, element));
|
||||
updateVisibleDivs();
|
||||
updateVisibleDivs('#rm_print_characters_block', true);
|
||||
}
|
||||
|
||||
function applyFilterToElement(tagIds, element) {
|
||||
|
@ -130,7 +130,7 @@ table.responsiveTable {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.hiddenByCharListScroll {
|
||||
.hiddenByScroll {
|
||||
visibility: hidden !important;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user