diff options
author | yfszzx <yfszzx@gmail.com> | 2022-10-22 02:16:22 +0000 |
---|---|---|
committer | yfszzx <yfszzx@gmail.com> | 2022-10-22 02:16:22 +0000 |
commit | 40ddb6df61564684263c7442bacf61efe3882b87 (patch) | |
tree | 7ab41e0b460526cc5e84cd736adb29184f6c9f66 /javascript | |
parent | 58ee008f0f559a947cc280a552d97050e638d611 (diff) | |
download | stable-diffusion-webui-gfx803-40ddb6df61564684263c7442bacf61efe3882b87.tar.gz stable-diffusion-webui-gfx803-40ddb6df61564684263c7442bacf61efe3882b87.tar.bz2 stable-diffusion-webui-gfx803-40ddb6df61564684263c7442bacf61efe3882b87.zip |
inspiration perfected
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/inspiration.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/javascript/inspiration.js b/javascript/inspiration.js index 791a80c9..39844544 100644 --- a/javascript/inspiration.js +++ b/javascript/inspiration.js @@ -1,5 +1,5 @@ function public_image_index_in_gallery(item, gallery){ - var imgs = gallery.querySelectorAll("img.h-full") + var imgs = gallery.querySelectorAll("img.h-full") var index; var i = 0; imgs.forEach(function(e){ @@ -7,18 +7,23 @@ function public_image_index_in_gallery(item, gallery){ index = i; i += 1; }); - var num = imgs.length / 2 - index = (index < num) ? index : (index - num) + var all_imgs = gallery.querySelectorAll("img") + if (all_imgs.length > imgs.length){ + var num = imgs.length / 2 + index = (index < num) ? index : (index - num) + } return index; } function inspiration_selected(name, name_list){ var btn = gradioApp().getElementById("inspiration_select_button") return [gradioApp().getElementById("inspiration_select_button").getAttribute("img-index")]; -} +} + function inspiration_click_get_button(){ gradioApp().getElementById("inspiration_get_button").click(); } + var inspiration_image_click = function(){ var index = public_image_index_in_gallery(this, gradioApp().getElementById("inspiration_gallery")); var btn = gradioApp().getElementById("inspiration_select_button"); @@ -32,16 +37,12 @@ document.addEventListener("DOMContentLoaded", function() { if (gallery) { var node = gallery.querySelector(".absolute.backdrop-blur.h-full") if (node) { - node.style.display = "None"; //parentNode.removeChild(node) + node.style.display = "None"; } gallery.querySelectorAll('img').forEach(function(e){ e.onclick = inspiration_image_click }); - } - - }); mutationObserver.observe( gradioApp(), { childList:true, subtree:true }); - }); |