mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	fix movingUI observer states
This commit is contained in:
		| @@ -534,12 +534,14 @@ export function dragElement(elmnt) { | |||||||
|  |  | ||||||
|     if (elmntHeader.length) { |     if (elmntHeader.length) { | ||||||
|         elmntHeader.off('mousedown').on('mousedown', (e) => { |         elmntHeader.off('mousedown').on('mousedown', (e) => { | ||||||
|  |             hasBeenDraggedByUser = true | ||||||
|  |             observer.observe(elmnt.get(0), { attributes: true, attributeFilter: ['style'] }); | ||||||
|             dragMouseDown(e); |             dragMouseDown(e); | ||||||
|         }); |         }); | ||||||
|         $(elmnt).off('mousedown').on('mousedown', () => { isMouseDown = true }) |         $(elmnt).off('mousedown').on('mousedown', () => { | ||||||
|     } else { |             isMouseDown = true | ||||||
|         elmnt.off('mousedown').on('mousedown', dragMouseDown); |             observer.observe(elmnt.get(0), { attributes: true, attributeFilter: ['style'] }); | ||||||
|  |         }) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const observer = new MutationObserver((mutations) => { |     const observer = new MutationObserver((mutations) => { | ||||||
| @@ -618,7 +620,7 @@ export function dragElement(elmnt) { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             //prevent resizing from top left into the top bar |             //prevent resizing from top left into the top bar | ||||||
|             if (top <= 40 && maxX >= topBarFirstX && left <= topBarFirstX |             if (top < 40 && maxX >= topBarFirstX && left <= topBarFirstX | ||||||
|             ) { |             ) { | ||||||
|                 console.debug('prevent topbar underlap resize') |                 console.debug('prevent topbar underlap resize') | ||||||
|                 elmnt.css('width', width - 1 + "px"); |                 elmnt.css('width', width - 1 + "px"); | ||||||
| @@ -674,8 +676,6 @@ export function dragElement(elmnt) { | |||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     observer.observe(elmnt.get(0), { attributes: true, attributeFilter: ['style'] }); |  | ||||||
|  |  | ||||||
|     function dragMouseDown(e) { |     function dragMouseDown(e) { | ||||||
|  |  | ||||||
|         if (e) { |         if (e) { | ||||||
| @@ -745,6 +745,7 @@ export function dragElement(elmnt) { | |||||||
|         $("body").css("overflow", ""); |         $("body").css("overflow", ""); | ||||||
|         // Clear the "data-dragged" attribute |         // Clear the "data-dragged" attribute | ||||||
|         elmnt.attr('data-dragged', 'false'); |         elmnt.attr('data-dragged', 'false'); | ||||||
|  |         observer.disconnect() | ||||||
|         console.debug(`Saving ${elmntName} UI position`) |         console.debug(`Saving ${elmntName} UI position`) | ||||||
|         saveSettingsDebounced(); |         saveSettingsDebounced(); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user