This repository was archived by the owner on Dec 26, 2018. It is now read-only.
This repository was archived by the owner on Dec 26, 2018. It is now read-only.
Prevent Swipe Examples #114
Open
Description
Loving how awesome this plugin so +1 for awesomeness!
I was utilizing a couple of swipes one in a parent and one in a child but I want to prevent propagation of swiping. I don't know the best way to implement this and maybe it's worth adding into the docs in some way. This is how I was able to prevent propagation to child elements and components.
<v-touch v-on:swipe="swipe">
<div>Swipe with me</div>
<div ref="preventSwipe">Don't swipe with me!!!</div>
<div>Swipe with me</div>
</v-touch>
Then in my methods I check whether the to prevent the swipe.
methods: {
swipe: function(e) {
let that = this;
// Prevent propagation for swipes inside the content box
var allowSwipe = true;
_.forEach(e.srcEvent.path, function(item, index){
if (item == that.$refs.preventSwipe) {
allowSwipe = false;
}
});
// Only continue if prevent swipe is false
if (allowSwipe) {
// Identify direction
if(e.offsetDirection == 4) {
bus.$emit('shift-item', 'previous');
}
if(e.offsetDirection == 2) {
bus.$emit('shift-item', 'next');
}
}
},
}
This works but I imagine there is a much smoother way to do it which might be worth putting in the docs.
Metadata
Metadata
Assignees
Labels
No labels