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

feat: handle drag the broweser canvas #715

Merged
merged 2 commits into from
Nov 3, 2024

Conversation

thvroyal
Copy link
Contributor

@thvroyal thvroyal commented Nov 2, 2024

Link to issue: #619

Description

Ability for a user to select the top of the browser controls and drag the selected window around the infinite canvas.

Screen.Recording.2024-11-02.at.16.44.36.mov

What is the purpose of this pull request?

  • New feature
  • Documentation update
  • Bug fix
  • Refactor
  • Release
  • Other

const transform = window.getComputedStyle(element).transform;
const matrix = new DOMMatrix(transform);

top += matrix.m42;
Copy link
Contributor

@Kitenite Kitenite Nov 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious what does this do? Seems like it's taking into account the transform better than before but why are you parsing into a matrix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To obtain the web frame's position, we should use getComputedStyle to retrieve the transform values, which cannot be obtained by offset properties. Since the values are presented in matrix format, I utilized the DOMMatrix class for easier manipulation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I learned something new today. Thanks!

Copy link
Contributor

@Kitenite Kitenite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works great. Awesome work as always!

@Kitenite Kitenite merged commit 4066c7b into onlook-dev:main Nov 3, 2024
@Kitenite Kitenite linked an issue Nov 3, 2024 that may be closed by this pull request
@thvroyal thvroyal deleted the feat/drag-window-frame branch November 3, 2024 16:20
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.

[feat] Ability to drag the window frame around the canvas
2 participants