koca / vue-use-gesture Goto Github PK
View Code? Open in Web Editor NEW๐ Bread n butter utility for component-tied mouse/touch gestures in Vue
Home Page: https://vue-use-gesture.netlify.app
License: MIT License
๐ Bread n butter utility for component-tied mouse/touch gestures in Vue
Home Page: https://vue-use-gesture.netlify.app
License: MIT License
Hey ๐
just want to let you know that the CodeSandbox links don't work (https://vue-use-gesture.netlify.app/docs/examples)
https://vue-use-gesture.netlify.app/docs
I guess the latest commit triggered something wrong on the netlify pipeline.
An example of use gesture would be very nice.
currently there are only examples in example-vue-2 for the other gestures,
I am interasted in a drag & rotate gesture
thanks for the amazing work, I actually struggle with interactjs...
actually I try to make a draggable component, in the end with scopes to put different content in it.
I used the use-drag file, but got some errors. here's my base app
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<dragcard/>
<dragcard/>
<dragcard/>
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
import dragcard from './components/use-drag.vue'
export default {
name: 'App',
components: {
HelloWorld,
dragcard
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
in your file I made the root div more generic to get a container to fill with other stuff. It works but it throws an error.
vueusegesture.esm.js?b67e:1312 Deprecation notice: When the domTarget
option is specified, you don't need to write useEffect(bind, [bind])
anymore: event binding is now made handled internally to this lib.
Next version won't return anything when domTarget
is provided, therefore your code will break if you try to call useEffect
.
I saw in the pinch demo that you use v-on="bind()" and not the domTarget in the gesture method. Ok, when I change this, comment out the { domTarget: refEl } and use the bind, Now error, but now interaction.
Would be nice to get a little help,
in the next step I will take over the drag into the gesture and integrate the pinch. but first i have to bring my knowledge of composition api up to date.
<template>
<div id="drag-card" ref="refEl" :style="transformStyle">
<!-- <div id="drag-card" ref="refEl" :style="transformStyle" v-on="bind()"> -->
<div class="area w-20 h-20 bg-blue-300 rounded-2xl"> </div>
</div>
</template>
<script>
import { useDrag, useSpring } from 'vue-use-gesture'
import { defineComponent, computed, ref } from '@vue/composition-api'
export default defineComponent({
setup() {
const refEl = ref()
const transform = useSpring({ x: 0, y: 0 })
// bind doesn't work for vue 2 bec of event names we can change listener names using vue-demi
const bind = useDrag(
({ down, movement: [mx, my] }) => {
transform.x = down ? mx : 0
transform.y = down ? my : 0
} ,
{ domTarget: refEl }
)
console.log(bind())
const transformStyle = computed(() => {
const style = { transform: `translate3d(${transform.x}px,${transform.y}px,0)` }
return style
})
return {
refEl,
bind,
transformStyle,
}
},
})
</script>
<style>
.area {
touch-action: none;
cursor: -webkit-grab;
cursor: grab;
}
</style>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.