Skip to content
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
Open
@Ethanhackett

Description

@Ethanhackett

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions