Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] useAbsolutePosition composable #2589

Merged
merged 2 commits into from
Feb 16, 2025
Merged

[Refactor] useAbsolutePosition composable #2589

merged 2 commits into from
Feb 16, 2025

Conversation

huchenlei
Copy link
Member

@huchenlei huchenlei commented Feb 16, 2025

This PR introduces a new composable useAbsolutePosition to handle absolute positioning calculations for elements on the LiteGraph canvas. The main changes involve extracting the positioning logic from TitleEditor.vue into a reusable composable that manages the conversion of canvas coordinates to client coordinates, handling scaling, and maintaining the position state. The TitleEditor component has been simplified by leveraging this new composable, replacing the manual style object initialization and coordinate calculations with cleaner, more maintainable code. The composable accepts a PositionConfig interface for position and size, along with optional scale and extra style properties, making it more flexible for reuse across different components that need canvas-to-screen coordinate conversion.

┆Issue is synchronized with this Notion page by Unito

@huchenlei huchenlei requested a review from a team as a code owner February 16, 2025 20:31
@huchenlei huchenlei merged commit d6a5dec into main Feb 16, 2025
10 checks passed
@huchenlei huchenlei deleted the absolute_position branch February 16, 2025 20:40
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