-
Notifications
You must be signed in to change notification settings - Fork 311
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: add Vue and Svelte target #512
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 5d022fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 5d022fa:
|
Thanks! I'll have a look over the week-end :) David |
Hey @wobsoriano, thanks a lot for this! I haven't looked through all the details but I guess exporting I've managed to integrate a svelte demo inside the main demo package using https://github.com/pngwn/svelte-adapter. You can try this locally and let me know if all of this works! |
Hi @dbismut !
Yeah according to the doc, we need to create {
"compilerOptions": {
"types": ["svelte-gesture/globals"]
}
}
I'll play around and update you! |
Hey @wobsoriano did you have the chance to look at this? Thanks! |
Hey @dbismut , sorry just now. Yes, I was able to test it locally and it works as expected! |
Demo when running removed video |
@wobsoriano sorry I'm late on this. All good then right? Not sure if the screen recording is supposed to show an error 😅 |
All good @dbismut ! Screen recording is just to show my local dev haha - it works |
Oh right :D Cool. While we're at it, we might as well release bindings for Vue. Let's see how easy that is. We were supposed to do this with @koca at some point, shouldn't be too hard. |
I have a working port of Vue as well https://github.com/wobsoriano/vuse-gesture … and Solid https://github.com/wobsoriano/solid-gesture |
❤️ how hard would it be to port both? Not sure about Solid but I think I could embed Vue in the demo the same way I did for Svelte. I would need to refactor some of the docs to make the docs either framework agnostic or find a way to have all APIs available. |
I already have a working port of Vue and can PR it. Do you want me to create a new PR or use this one? |
Let's do this one :) thanks! |
Added vue target @dbismut . Sample usage: <script setup>
import { useSpring } from 'vue-use-spring'
import { normalizeProps, useDrag } from '@use-gesture/vue'
const position = useSpring({ x: 0, y: 0 })
const bind = useDrag(({ down, movement: [mx, my] }) => {
position.x = down ? mx : 0
position.y = down ? my : 0
})
</script>
<template>
<div
id="box"
v-bind="normalizeProps(bind())"
:style="{
touchAction: 'none',
transform: `translate(${position.x}px, ${position.y}px)`,
}"
/>
</template> |
Hey @wobsoriano sorry I'm a bit drowning with work atm. Just a quick question, do we have to use |
This now throws an error, I'm not sure why, it was working fine before
deps: update
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
About normalizeProps, I'll try to integrate a way to have this inside |
Yeah we have to, or integrate it internally because of this const eventMap: Dict = {
onKeyDown: 'onKeydown',
onKeyup: 'onKeyup',
onPointerCancel: 'onPointercancel',
onPointerDown: 'onPointerdown',
onPointerMove: 'onPointermove',
onPointerEnter: 'onPointerenter',
onPointerLeave: 'onPointerleave',
onPointerUp: 'onPointerup',
onWheel: 'onWheel',
onScroll: 'onScroll'
} |
@wobsoriano I've added a way to pass normalize function to the gesture controller to make this cleaner for the end user. <script setup>
import { useSpring } from 'vue-use-spring'
import { useDrag } from '@use-gesture/vue'
const position = useSpring({ x: 0, y: 0 })
const bind = useDrag(({ down, movement: [mx, my] }) => {
position.x = down ? mx : 0
position.y = down ? my : 0
})
</script>
<template>
<div
id="box"
v-on="bind()"
:style="{
touchAction: 'none',
transform: `translate(${position.x}px, ${position.y}px)`,
}"
/>
</template> |
Looks good to me @dbismut. I forgot about the |
Initial PR that adds Svelte target package. It can be used together with Svelte's built-in
spring
function:I have no experience with changesets so I just copy-pasted some configs in
package.json