jerrybendy/vue-touch-events

Add parameter when we v-touch:swipe="myMethod(direction, myOtherParam)"

Nordes opened this issue ยท 4 comments

Hi,

As the title says, it would be nice to have something like a binding with extra parameters.

Example
v-touch:swipe="myMethod(direction, myOtherParam)"

I'm sorry to reply you too late, I'm too busy these days.

If you have some good solution to handle this issue, you can give me a PR, and I'll merge it soon. ๐Ÿ˜Š

I'll check what I can do. I have quite a good load of work also on my side.

I think it is difficult to implement this feature. v-touch is a custom directive, not similar to v-on.

If you put myMethod(direction, myOtherParam) as parameter, actually the parameter send to v-touch is the result of this expression. And it's meaningless for v-touch.

If you really want to do this, maybe you can write like that:

<div v-touch:swipe="myMethod(myOtherParam)">Swipe</div>
export default {
  methods: {
    myMethod (param) {
      return function(dir) {
        console.log(dir, param);
      }
    }
  }
}

Just return a function and append your own parameters is okay :)