motiondivision / motiondivision/motion

[BUG] dragConstraints by ref doesn't consider changes after initial render

Open
#1,827 9 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
33.7k
Forks
1.4k
Avg merge
1d 10h
Merged PRs (30d)
14

Description

1. Read the FAQs 👇

2. Describe the bug

If dragConstraints are set by giving a ref of an element, then the size of the draggable element is based off the initial render and not the current size.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/s/framer-motion-drag-constraints-with-changing-size-7ixkj0?file=/src/Example.tsx

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Go to Sandbox.
  2. Click on button in top left corner.
  3. Draggable area for box is the same.

5. Expected behavior

The draggable area should change to accomodate the change in size.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CodeSandbox reproduction in src/Example.tsx and run it to observe the constraint after the button changes the element size. Trace the dragConstraints ref handling from the reproduced behavior into the relevant source and tests. Done means the draggable area updates to accommodate the changed size.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.