diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-09-21 06:49:07 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-09-21 06:49:07 +0000 |
commit | 4b26b50df0b417216ff4c12ce115394a828cdd05 (patch) | |
tree | 88e0fe6a6b987d320c56d6c30fd743d3edd2df83 /javascript | |
parent | 254da5d127d1ac42803fb5db61857bfb5005b655 (diff) | |
parent | b5693699b8460008ca92544b42f6bc394078ee4d (diff) | |
download | stable-diffusion-webui-gfx803-4b26b50df0b417216ff4c12ce115394a828cdd05.tar.gz stable-diffusion-webui-gfx803-4b26b50df0b417216ff4c12ce115394a828cdd05.tar.bz2 stable-diffusion-webui-gfx803-4b26b50df0b417216ff4c12ce115394a828cdd05.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/dragdrop.js | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/javascript/dragdrop.js b/javascript/dragdrop.js index 29e26766..c01f66e2 100644 --- a/javascript/dragdrop.js +++ b/javascript/dragdrop.js @@ -10,22 +10,34 @@ function dropReplaceImage( imgWrap, files ) { } imgWrap.querySelector('.modify-upload button + button, .touch-none + div button + button')?.click(); - window.requestAnimationFrame( () => { + const callback = () => { const fileInput = imgWrap.querySelector('input[type="file"]'); if ( fileInput ) { fileInput.files = files; fileInput.dispatchEvent(new Event('change')); } - }); -} - -function pressClearBtn(hoverElems) { - //Find all buttons hovering over the image box - let btns = Array.from(hoverElems.querySelectorAll("button")) - - //Press the last btn which will be the X button - if (btns.length) - btns[btns.length-1].click() + }; + + if ( imgWrap.closest('#pnginfo_image') ) { + // special treatment for PNG Info tab, wait for fetch request to finish + const oldFetch = window.fetch; + window.fetch = async (input, options) => { + const response = await oldFetch(input, options); + if ( 'api/predict/' === input ) { + const content = await response.text(); + window.fetch = oldFetch; + window.requestAnimationFrame( () => callback() ); + return new Response(content, { + status: response.status, + statusText: response.statusText, + headers: response.headers + }) + } + return response; + }; + } else { + window.requestAnimationFrame( () => callback() ); + } } window.document.addEventListener('dragover', e => { @@ -36,13 +48,7 @@ window.document.addEventListener('dragover', e => { } e.stopPropagation(); e.preventDefault(); - - if (e.dataTransfer) - e.dataTransfer.dropEffect = 'copy'; - - //If is gr.Interface clear image on hover - if (target.previousElementSibling) - pressClearBtn(target.previousElementSibling) + e.dataTransfer.dropEffect = 'copy'; }); window.document.addEventListener('drop', e => { |