stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

Optimize ar preview

Open ProblemShooter opened this issue 2 months ago • 0 comments

Refactored the dimensionChange logic and AR preview handling for better performance and readability. The code now caches repeated DOM queries like gradioApp() and the AR preview div to avoid unnecessary lookups on every input event. Type conversions were simplified, and redundant calculations were reduced for efficiency.

The AR preview rendering now uses requestAnimationFrame instead of setTimeout for smoother updates, ensuring better user experience. Event listeners for width and height inputs are added only once, and input value handling is streamlined for clarity. Overall, this reduces memory usage and improves responsiveness when updating image dimensions.

Additional optimizations include combining repetitive logic for tab selection, scaling, and centering calculations, making the code easier to maintain and extend in the future. This commit keeps all existing functionality intact while improving performance and maintainability.

ProblemShooter avatar Sep 27 '25 13:09 ProblemShooter