From d75b30d51a8c553cb9aaf61621b2390f80fda993 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 16 Jun 2024 14:56:08 +0300 Subject: [PATCH] Don't auto-adjust scroll height if not in viewport --- public/scripts/extensions/stable-diffusion/index.js | 4 ++++ public/scripts/utils.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js index a55d5efd0..a81c3dc83 100644 --- a/public/scripts/extensions/stable-diffusion/index.js +++ b/public/scripts/extensions/stable-diffusion/index.js @@ -712,6 +712,10 @@ function onChatChanged() { } function adjustElementScrollHeight(){ + if (!$('.sd_settings').is(':visible')) { + return; + } + resetScrollHeight($('#sd_prompt_prefix')); resetScrollHeight($('#sd_negative_prompt')); resetScrollHeight($('#sd_character_prompt')); diff --git a/public/scripts/utils.js b/public/scripts/utils.js index f688d5aa4..c6f638f7c 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -292,6 +292,9 @@ export function throttle(func, limit = 300) { * @returns {boolean} True if the element is in the viewport, false otherwise. */ export function isElementInViewport(el) { + if (!el) { + return false; + } if (typeof jQuery === 'function' && el instanceof jQuery) { el = el[0]; }