mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-07 05:08:01 +01:00
Remove getComputedStyle calls
This commit is contained in:
parent
a57d994913
commit
684ce999f3
@ -9234,12 +9234,10 @@ jQuery(async function () {
|
|||||||
* @param {HTMLTextAreaElement} e Textarea element to auto-fit
|
* @param {HTMLTextAreaElement} e Textarea element to auto-fit
|
||||||
*/
|
*/
|
||||||
function autoFitEditTextArea(e) {
|
function autoFitEditTextArea(e) {
|
||||||
const computedStyle = window.getComputedStyle(e);
|
|
||||||
const maxHeight = parseInt(computedStyle.maxHeight, 10);
|
|
||||||
scroll_holder = chatElement[0].scrollTop;
|
scroll_holder = chatElement[0].scrollTop;
|
||||||
e.style.height = computedStyle.minHeight;
|
e.style.height = '0px';
|
||||||
const newHeight = e.scrollHeight + 4;
|
const newHeight = e.scrollHeight + 4;
|
||||||
e.style.height = (newHeight < maxHeight) ? `${newHeight}px` : `${maxHeight}px`;
|
e.style.height = `${newHeight}px`;
|
||||||
is_use_scroll_holder = true;
|
is_use_scroll_holder = true;
|
||||||
}
|
}
|
||||||
const autoFitEditTextAreaDebounced = debouncedThrottle(autoFitEditTextArea, debounce_timeout.short);
|
const autoFitEditTextAreaDebounced = debouncedThrottle(autoFitEditTextArea, debounce_timeout.short);
|
||||||
|
@ -694,16 +694,13 @@ const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|||||||
* this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height)
|
* this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height)
|
||||||
*/
|
*/
|
||||||
function autoFitSendTextArea() {
|
function autoFitSendTextArea() {
|
||||||
// Needs to be pulled dynamically because it is affected by font size changes
|
|
||||||
const computedStyle = window.getComputedStyle(sendTextArea);
|
|
||||||
const originalScrollBottom = chatBlock.scrollHeight - (chatBlock.scrollTop + chatBlock.offsetHeight);
|
const originalScrollBottom = chatBlock.scrollHeight - (chatBlock.scrollTop + chatBlock.offsetHeight);
|
||||||
if (Math.ceil(sendTextArea.scrollHeight + 3) >= Math.floor(sendTextArea.offsetHeight)) {
|
if (Math.ceil(sendTextArea.scrollHeight + 3) >= Math.floor(sendTextArea.offsetHeight)) {
|
||||||
const sendTextAreaMinHeight = computedStyle.minHeight;
|
const sendTextAreaMinHeight = '0px';
|
||||||
sendTextArea.style.height = sendTextAreaMinHeight;
|
sendTextArea.style.height = sendTextAreaMinHeight;
|
||||||
}
|
}
|
||||||
const maxHeight = parseInt(computedStyle.maxHeight, 10);
|
|
||||||
const newHeight = sendTextArea.scrollHeight + 3;
|
const newHeight = sendTextArea.scrollHeight + 3;
|
||||||
sendTextArea.style.height = (newHeight < maxHeight) ? `${newHeight}px` : `${maxHeight}px`;
|
sendTextArea.style.height = `${newHeight}px`;
|
||||||
|
|
||||||
if (!isFirefox) {
|
if (!isFirefox) {
|
||||||
const newScrollTop = Math.round(chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom));
|
const newScrollTop = Math.round(chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user