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