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

replace react-use-gesture to @use-gesture/react #257

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

wey-gu
Copy link
Contributor

@wey-gu wey-gu commented Jul 25, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[x] Other... Please describe:

What is the current behavior?

react-use-gesture is not maintained and @use-gesture/react is the successor

Issue Number: N/A

What is the new behavior?

Warning of react-use-gesture during npm i

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Copy link

vercel bot commented Jul 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
reagraph ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2024 6:14am

Copy link

netlify bot commented Jul 25, 2024

Deploy Preview for reagraph ready!

Name Link
🔨 Latest commit b94a0d3
🔍 Latest deploy log https://app.netlify.com/sites/reagraph/deploys/66a33e81eac55c0008bdc73d
😎 Deploy Preview https://deploy-preview-257--reagraph.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@ghsteff ghsteff left a comment

Choose a reason for hiding this comment

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

Tested dragging on desktop and mobile 👍

Copy link
Contributor

@ghsteff ghsteff left a comment

Choose a reason for hiding this comment

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

Oops was testing on the wrong branch 😅 dragging nodes doesn't seem to be working

@ghsteff
Copy link
Contributor

ghsteff commented Jul 25, 2024

Here's a video of the Nodes/Draggable story. Is this working correctly on your machine @wey-gu ?

Screen.Recording.2024-07-25.at.11.56.47.AM.mov

Comment on lines 64 to 78
onDrag: ({ event }) => {
// Compute normalized mouse coordinates (screen space)
const nx =
((event.clientX - (clientRect?.left ?? 0)) / size.width) * 2 - 1;
const ny =
-((event.clientY - (clientRect?.top ?? 0)) / size.height) * 2 + 1;
let clientX, clientY;
if (event instanceof MouseEvent || event instanceof PointerEvent) {
clientX = event.clientX;
clientY = event.clientY;
} else if (event instanceof TouchEvent) {
clientX = event.touches[0].clientX;
clientY = event.touches[0].clientY;
} else {
return;
}

const nx = ((clientX - (clientRect?.left ?? 0)) / size.width) * 2 - 1;
const ny = -((clientY - (clientRect?.top ?? 0)) / size.height) * 2 + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm playing around with this and the types for event seem wrong. It's hitting the else { return } block every time

This should work with no ts complaints tho

      onDrag: ({ xy }) => {
        // Compute normalized mouse coordinates (screen space)
        const nx = ((xy[0] - (clientRect?.left ?? 0)) / size.width) * 2 - 1;
        const ny = -((xy[1] - (clientRect?.top ?? 0)) / size.height) * 2 + 1;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do tomorrow, thanks!🫡

Copy link
Contributor

@ghsteff ghsteff left a comment

Choose a reason for hiding this comment

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

🚀

@amcdnl amcdnl merged commit 5e64581 into reaviz:master Jul 26, 2024
7 checks passed
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.

3 participants