aboutsummaryrefslogtreecommitdiffstats
path: root/javascript/imageMaskFix.js
diff options
context:
space:
mode:
authorRoman Beltiukov <maybe.hello.world@gmail.com>2023-05-25 22:10:10 +0000
committerGitHub <noreply@github.com>2023-05-25 22:10:10 +0000
commitb2530c965c2afd5512c5f9020251fd4be8f067e5 (patch)
tree0c1620e00ac4eddea514706a5c3bf3e03bd46c70 /javascript/imageMaskFix.js
parent09d9c3d287ee4543d285e0fde8b81603c9751a7e (diff)
parenta6e653be26cc05f4438145fa0082816e9fbbf5fc (diff)
downloadstable-diffusion-webui-gfx803-b2530c965c2afd5512c5f9020251fd4be8f067e5.tar.gz
stable-diffusion-webui-gfx803-b2530c965c2afd5512c5f9020251fd4be8f067e5.tar.bz2
stable-diffusion-webui-gfx803-b2530c965c2afd5512c5f9020251fd4be8f067e5.zip
Merge branch 'dev' into master
Diffstat (limited to 'javascript/imageMaskFix.js')
-rw-r--r--javascript/imageMaskFix.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/javascript/imageMaskFix.js b/javascript/imageMaskFix.js
index a612705d..3c9b8a6f 100644
--- a/javascript/imageMaskFix.js
+++ b/javascript/imageMaskFix.js
@@ -4,17 +4,16 @@
*/
function imageMaskResize() {
const canvases = gradioApp().querySelectorAll('#img2maskimg .touch-none canvas');
- if ( ! canvases.length ) {
- canvases_fixed = false; // TODO: this is unused..?
- window.removeEventListener( 'resize', imageMaskResize );
- return;
+ if (!canvases.length) {
+ window.removeEventListener('resize', imageMaskResize);
+ return;
}
const wrapper = canvases[0].closest('.touch-none');
const previewImage = wrapper.previousElementSibling;
- if ( ! previewImage.complete ) {
- previewImage.addEventListener( 'load', imageMaskResize);
+ if (!previewImage.complete) {
+ previewImage.addEventListener('load', imageMaskResize);
return;
}
@@ -24,15 +23,15 @@ function imageMaskResize() {
const nh = previewImage.naturalHeight;
const portrait = nh > nw;
- const wW = Math.min(w, portrait ? h/nh*nw : w/nw*nw);
- const wH = Math.min(h, portrait ? h/nh*nh : w/nw*nh);
+ const wW = Math.min(w, portrait ? h / nh * nw : w / nw * nw);
+ const wH = Math.min(h, portrait ? h / nh * nh : w / nw * nh);
wrapper.style.width = `${wW}px`;
wrapper.style.height = `${wH}px`;
wrapper.style.left = `0px`;
wrapper.style.top = `0px`;
- canvases.forEach( c => {
+ canvases.forEach(c => {
c.style.width = c.style.height = '';
c.style.maxWidth = '100%';
c.style.maxHeight = '100%';
@@ -41,4 +40,4 @@ function imageMaskResize() {
}
onUiUpdate(imageMaskResize);
-window.addEventListener( 'resize', imageMaskResize);
+window.addEventListener('resize', imageMaskResize);