Panning Touch/Mouse Action
Quasar offers full-featured Vue directives that can totally replace libraries like Hammerjs: v-touch-pan
, v-touch-swipe
and v-touch-hold
.
These directives also work with mouse events, not only touch events, so you are able to build cool functionality for your App on desktops too.
We will be describing v-touch-pan
on the lines below.
Installation
Edit /quasar.conf.js
:
framework: { |
Basic Usage
<div v-touch-pan="handler">...</div> |
Handler Parameter
The handler
function/method will be called by the directive when a pan
touch (or with mouse) action is taking place (any change in touch position triggers a call) on the DOM element and it receives the following parameter:
{ |
Modifiers
Property | Description |
---|---|
horizontal | Capture only horizontal panning. |
vertical | Capture only vertical panning. |
noMouse | Avoid capturing mouse events too. |
stop | Stop event propagation once panning has been detected. |
prevent | Prevent default browser behavior of the event once panning has been detected. |
mightPrevent | If not using prevent prop, but you might call event.preventDefault() , specify this modifier otherwise you’ll get console warnings. |
Use horizontal
or vertical
when you only want to capture horizontal or vertical swipes.
<div v-touch-pan.horizontal="userHasPanned">...</div> |
Avoid Capturing Mouse Events
When you don’t want to capture mouse actions too, use the noMouse
modifier:
<!-- |
Preventing Scroll (on touch capable devices)
By default, the directive does not block page scrolling. If you want to prevent scrolling, then use the prevent
modifier.
<div v-touch-pan.prevent="userHasPanned">...</div> |