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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(useDraggable): allowing calculations of bounds with fixed element #3335

Merged
merged 1 commit into from Aug 25, 2023

Conversation

linspw
Copy link
Contributor

@linspw linspw commented Aug 22, 2023

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Description

The feature's idea is to be able to pass a fixed container for bounds calculations. This is especially useful when you have another calculation scale or when working with CSS Transforms (translation). This feature allows a calculation relative to the element you choose.

Additional context

There is a similar initiative in this PR #3219.


馃 Generated by Copilot at b1328a2

Add custom container option to useDraggable. This lets the user choose a different element than the document body as the reference for the draggable element's position and boundaries.

馃 Generated by Copilot at b1328a2

  • Add containerElement property to UseDraggableOptions interface to allow specifying a custom element for bounds calculation (link)
  • Pass containerElement from options to useDraggable function (link)
  • Use containerElement or target to get the bounding rectangle of the container element in useDraggable function (link)
  • Adjust x and y values of pos object based on the relative position of the mouse pointer inside the container element (link)

@linspw linspw changed the title feat: allowing calculations of bounds with fixed elements feat: allowing calculations of bounds with fixed element Aug 22, 2023
@linspw linspw marked this pull request as ready for review August 22, 2023 23:56
@linspw linspw changed the title feat: allowing calculations of bounds with fixed element feat(useDraggable): allowing calculations of bounds with fixed element Aug 23, 2023
@antfu antfu added this pull request to the merge queue Aug 25, 2023
@linspw
Copy link
Contributor Author

linspw commented Aug 25, 2023

@antfu , sorry to see this right on top of the merge, but maybe I need to make a little tweak to the move handler, I think it needs to consider bounds too

Maybe doing everything in PR is just better what do you think?

Merged via the queue into vueuse:main with commit c08e5e0 Aug 25, 2023
5 checks passed
@linspw
Copy link
Contributor Author

linspw commented Aug 25, 2023

Just to register the adjustment can come later, it's not a matter of breaking anything.

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.

None yet

2 participants