Skip to content

Conversation

@ProblemShooter
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant