Top Related Projects
A javascript library for multi-touch gestures :// You can touch this
Unopinionated utilities for resizeable split views
🚀 Performance focused, lightweight scroll animation library 🚀
Parallax Engine that reacts to the orientation of a smart device
Smooth scrolling for the web
:ok_hand: Drag and drop so simple it hurts
Quick Overview
Vue-touch is a touch events plugin for Vue.js, providing a set of custom directives for adding touch gestures to Vue applications. It allows developers to easily implement swipe, tap, pan, and other touch interactions in their Vue projects, enhancing the user experience on mobile and touch-enabled devices.
Pros
- Seamless integration with Vue.js applications
- Supports a wide range of touch gestures (swipe, tap, pan, etc.)
- Easy to use with simple directives
- Customizable options for fine-tuning gesture recognition
Cons
- Limited documentation and examples
- Not actively maintained (last update was several years ago)
- May not be fully compatible with the latest Vue.js versions
- Lacks support for more complex multi-touch gestures
Code Examples
- Basic swipe gesture:
<template>
<div v-touch:swipe="onSwipe">Swipe me!</div>
</template>
<script>
export default {
methods: {
onSwipe(direction) {
console.log(`Swiped ${direction}`);
}
}
}
</script>
- Tap gesture with options:
<template>
<div v-touch:tap="onTap" :touch-options="{ touchHoldTolerance: 400 }">
Tap me!
</div>
</template>
<script>
export default {
methods: {
onTap() {
console.log('Tapped!');
}
}
}
</script>
- Pan gesture:
<template>
<div v-touch:pan="onPan">Pan me!</div>
</template>
<script>
export default {
methods: {
onPan(direction) {
console.log(`Panned ${direction}`);
}
}
}
</script>
Getting Started
To use Vue-touch in your Vue.js project:
-
Install the package:
npm install vue-touch@next
-
Import and use the plugin in your main.js file:
import Vue from 'vue' import VueTouch from 'vue-touch' Vue.use(VueTouch, { name: 'v-touch' })
-
Use the directives in your Vue components:
<template> <div v-touch:swipe="onSwipe">Swipe me!</div> </template> <script> export default { methods: { onSwipe(direction) { console.log(`Swiped ${direction}`); } } } </script>
Competitor Comparisons
A javascript library for multi-touch gestures :// You can touch this
Pros of Hammer.js
- Framework-agnostic, can be used with any JavaScript project
- More comprehensive touch gesture support, including multi-touch and custom gestures
- Larger community and more frequent updates
Cons of Hammer.js
- Requires more setup and configuration for use with Vue.js projects
- Larger file size, which may impact performance for smaller applications
Code Comparison
Vue-touch:
Vue.use(VueTouch, {name: 'v-touch'})
<v-touch v-on:swipeleft="onSwipeLeft">Swipe me!</v-touch>
Hammer.js:
var hammer = new Hammer(element);
hammer.on('swipeleft', function(ev) {
console.log('Swiped left!');
});
Summary
Hammer.js is a more versatile and powerful touch gesture library, offering broader support for various gestures and compatibility with different frameworks. However, Vue-touch provides a more seamless integration with Vue.js projects, requiring less setup and configuration. The choice between the two depends on the specific needs of your project, with Hammer.js being better suited for complex touch interactions across multiple platforms, while Vue-touch excels in simplicity for Vue.js applications.
Unopinionated utilities for resizeable split views
Pros of Split
- Framework-agnostic, can be used with any JavaScript project
- Lightweight and focused on split functionality
- Supports both horizontal and vertical splitting
Cons of Split
- Limited to splitting functionality, not a comprehensive touch events library
- Requires more setup for complex touch interactions
- May need additional libraries for advanced touch gestures
Code Comparison
Split:
Split(['#left', '#right'], {
sizes: [25, 75],
minSize: 100,
expandToMin: true,
gutterSize: 10,
});
Vue-Touch:
Vue.use(VueTouch, { name: 'v-touch' })
<v-touch v-on:swipeleft="onSwipeLeft">
<div>Swipe me!</div>
</v-touch>
Key Differences
- Split focuses on creating resizable split views, while Vue-Touch provides a wide range of touch gestures
- Vue-Touch is specifically designed for Vue.js applications, whereas Split can be used in any JavaScript environment
- Split offers more customization options for split functionality, while Vue-Touch provides easier implementation of various touch events
Use Cases
- Choose Split for projects requiring resizable split views, regardless of the framework
- Opt for Vue-Touch in Vue.js applications needing comprehensive touch event handling
Community and Maintenance
- Split: Active development, regular updates
- Vue-Touch: Less frequent updates, primarily maintained by the Vue.js community
🚀 Performance focused, lightweight scroll animation library 🚀
Pros of Sal
- Lightweight and dependency-free, making it easier to integrate into projects
- Supports a wider range of scroll animations and effects
- More actively maintained with recent updates
Cons of Sal
- Less Vue-specific functionality compared to Vue Touch
- May require more manual configuration for complex animations
- Smaller community and fewer Vue-specific resources available
Code Comparison
Vue Touch (event handling):
<template>
<div v-touch:swipe="onSwipe">Swipe me</div>
</template>
<script>
export default {
methods: {
onSwipe(direction) {
console.log('Swiped:', direction)
}
}
}
</script>
Sal (scroll animation):
<div data-sal="slide-up" data-sal-duration="300" data-sal-easing="ease-out-bounce">
Animate on scroll
</div>
<script>
import sal from 'sal.js'
sal()
</script>
While Vue Touch focuses on touch events and gestures, Sal is primarily used for scroll-based animations. Vue Touch integrates more seamlessly with Vue.js components, whereas Sal can be used in any JavaScript project, including Vue applications. The code examples demonstrate the different approaches: Vue Touch uses Vue directives for event handling, while Sal relies on data attributes for animation configuration.
Parallax Engine that reacts to the orientation of a smart device
Pros of Parallax
- More versatile, not limited to Vue.js applications
- Offers a wider range of parallax effects and animations
- Lightweight and easy to implement without a framework dependency
Cons of Parallax
- Less integrated with Vue.js ecosystem
- May require more manual setup and configuration
- Not specifically optimized for touch events like Vue-touch
Code Comparison
Vue-touch example:
import Vue from 'vue'
import VueTouch from 'vue-touch'
Vue.use(VueTouch, {name: 'v-touch'})
Parallax example:
import Parallax from 'parallax-js'
var scene = document.getElementById('scene');
var parallaxInstance = new Parallax(scene);
Summary
Parallax is a more general-purpose library for creating parallax effects, while Vue-touch is specifically designed for handling touch events in Vue.js applications. Parallax offers more flexibility and can be used in various contexts, but it may require more setup. Vue-touch integrates seamlessly with Vue.js and provides optimized touch event handling, but it's limited to Vue.js projects. The choice between the two depends on the specific requirements of your project and whether you're working within the Vue.js ecosystem.
Smooth scrolling for the web
Pros of iScroll
- More comprehensive scrolling solution with support for various scroll types (vertical, horizontal, infinite, etc.)
- Better performance optimization for mobile devices
- Wider browser compatibility, including older versions
Cons of iScroll
- Larger file size and potentially more complex implementation
- Not specifically designed for Vue.js integration
- May require more manual configuration for advanced features
Code Comparison
vue-touch example:
Vue.use(VueTouch, {name: 'v-touch'})
<v-touch v-on:swipeleft="onSwipeLeft">Swipe me!</v-touch>
iScroll example:
var myScroll = new IScroll('#wrapper', {
scrollX: true,
scrollY: true,
mouseWheel: true
});
<div id="wrapper">
<div id="scroller">
<!-- Content here -->
</div>
</div>
Summary
While vue-touch is specifically designed for Vue.js and focuses on touch events, iScroll provides a more comprehensive scrolling solution with broader compatibility. vue-touch offers easier integration with Vue.js projects, but iScroll may be more suitable for complex scrolling requirements and performance-critical mobile applications. The choice between the two depends on the specific needs of your project and the level of scrolling functionality required.
:ok_hand: Drag and drop so simple it hurts
Pros of Dragula
- Framework-agnostic, can be used with any JavaScript project
- Supports nested draggable elements
- Lightweight and has minimal dependencies
Cons of Dragula
- Lacks built-in touch support, requiring additional configuration for mobile
- Not specifically designed for Vue.js integration
Code Comparison
Vue-touch (for Vue 2.x):
import Vue from 'vue'
import VueTouch from 'vue-touch'
Vue.use(VueTouch, {name: 'v-touch'})
Dragula:
import dragula from 'dragula'
dragula([document.querySelector('#left'), document.querySelector('#right')])
Key Differences
Vue-touch is specifically designed for Vue.js applications, providing touch gesture support. It's ideal for adding swipe, tap, and other touch interactions to Vue components.
Dragula, on the other hand, is a versatile drag-and-drop library that works across different frameworks. It excels in creating drag-and-drop interfaces but doesn't inherently support touch gestures beyond dragging.
While Vue-touch integrates seamlessly with Vue.js, Dragula requires additional setup for Vue integration but offers more flexibility for use in various project types.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
This plugin is deprecated and not maintained anymore.
vue-touch
Touch events plugin for Vue.js. This plugin does not support Vue 2.0 yet.
This is a directive wrapper for Hammer.js 2.0.
Install
This branch is only compatible with Vue 1.0. For the Vue 2.0 compatible rewrite, see the
next
branch
CommonJS
-
Available through npm as
vue-touch
.var VueTouch = require('vue-touch') Vue.use(VueTouch)
Direct include
- You can also directly include it with a
<script>
tag when you have Vue and Hammer.js already included globally. It will automatically install itself, and will add a globalVueTouch
.
Usage
Using the v-touch
directive
<a v-touch:tap="onTap">Tap me!</a>
<div v-touch:swipeleft="onSwipeLeft">Swipe me!</div>
Configuring Recognizer Options
There are two ways to customize recognizer options such as direction
and threshold
. The first one is setting global options:
// change the threshold for all swipe recognizers
VueTouch.config.swipe = {
threshold: 200
}
Or, you can use the v-touch-options
directive to configure the behavior on a specific element:
<!-- detect only horizontal pans with a threshold of 100 -->
<a
v-touch:pan="onPan"
v-touch-options:pan="{ direction: 'horizontal', threshold: 100 }">
</a>
Registering Custom Events
// example registering a custom doubletap event.
// the `type` indicates the base recognizer to use from Hammer
// all other options are Hammer recognizer options.
VueTouch.registerCustomEvent('doubletap', {
type: 'tap',
taps: 2
})
<a v-touch:doubletap="onDoubleTap"></a>
See Hammer.js documentation for all available events.
See /example
for a multi-event demo. To build it, run npm install && npm run build
.
License
Top Related Projects
A javascript library for multi-touch gestures :// You can touch this
Unopinionated utilities for resizeable split views
🚀 Performance focused, lightweight scroll animation library 🚀
Parallax Engine that reacts to the orientation of a smart device
Smooth scrolling for the web
:ok_hand: Drag and drop so simple it hurts
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot