Commit 704036ff authored by AUTOMATIC's avatar AUTOMATIC
Browse files

make aspect ratio overlay work regardless of selected localization

parent 02e4d469
Loading
Loading
Loading
Loading
+17 −19
Original line number Diff line number Diff line
@@ -3,12 +3,12 @@ let currentWidth = null;
let currentHeight = null;
let arFrameTimeout = setTimeout(function(){},0);

function dimensionChange(e,dimname){
function dimensionChange(e, is_width, is_height){

	if(dimname == 'Width'){
	if(is_width){
		currentWidth = e.target.value*1.0
	}
	if(dimname == 'Height'){
	if(is_height){
		currentHeight = e.target.value*1.0
	}

@@ -99,21 +99,19 @@ onUiUpdate(function(){
	if(inImg2img){
		let inputs = gradioApp().querySelectorAll('input');
		inputs.forEach(function(e){
			let parentLabel = e.parentElement.querySelector('label')
			if(parentLabel && parentLabel.innerText){
				if(!e.classList.contains('scrollwatch')){
					if(parentLabel.innerText == 'Width' || parentLabel.innerText == 'Height'){
						e.addEventListener('input', function(e){dimensionChange(e,parentLabel.innerText)} )
		    var is_width = e.parentElement.id == "img2img_width"
		    var is_height = e.parentElement.id == "img2img_height"

			if((is_width || is_height) && !e.classList.contains('scrollwatch')){
				e.addEventListener('input', function(e){dimensionChange(e, is_width, is_height)} )
				e.classList.add('scrollwatch')
			}
					if(parentLabel.innerText == 'Width'){
			if(is_width){
				currentWidth = e.value*1.0
			}
					if(parentLabel.innerText == 'Height'){
			if(is_height){
				currentHeight = e.value*1.0
			}
				}
			} 
		})
	}
});
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ function dropReplaceImage( imgWrap, files ) {
window.document.addEventListener('dragover', e => {
    const target = e.composedPath()[0];
    const imgWrap = target.closest('[data-testid="image"]');
    if ( !imgWrap && target.placeholder.indexOf("Prompt") == -1) {
    if ( !imgWrap && target.placeholder && target.placeholder.indexOf("Prompt") == -1) {
        return;
    }
    e.stopPropagation();
+2 −2
Original line number Diff line number Diff line
@@ -879,8 +879,8 @@ def create_ui(wrap_gradio_gpu_call):
                sampler_index = gr.Radio(label='Sampling method', choices=[x.name for x in samplers_for_img2img], value=samplers_for_img2img[0].name, type="index")

                with gr.Group():
                    width = gr.Slider(minimum=64, maximum=2048, step=64, label="Width", value=512)
                    height = gr.Slider(minimum=64, maximum=2048, step=64, label="Height", value=512)
                    width = gr.Slider(minimum=64, maximum=2048, step=64, label="Width", value=512, elem_id="img2img_width")
                    height = gr.Slider(minimum=64, maximum=2048, step=64, label="Height", value=512, elem_id="img2img_height")

                with gr.Row():
                    restore_faces = gr.Checkbox(label='Restore faces', value=False, visible=len(shared.face_restorers) > 1)