Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure swipeTolerance is taken into consideration for the Y axis #65

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

cameronbatty
Copy link
Contributor

When swiping on the Y axis the swipeTolerance option is disregarded causing events to fire no matter the distance swiped. X axis works as expected.

@jerrybendy
Copy link
Owner

I have tried this for so many times, but it works well

// Only emit the specified event when it has modifiers
if ($this.callbacks['swipe.' + direction]) {
triggerEvent(event, this, 'swipe.' + direction, direction);
if (distanceY > swipeOutBounded || distanceX > swipeOutBounded) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the code runs into the code block of L160, it means a swipe event is detected. This event only has two possible directions, top-bottom and left-right. So this judgement has no differece to the old version.

Copy link
Contributor Author

@cameronbatty cameronbatty Jun 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have originally supplied an example, sorry:

<template>
    <div class="swipe" v-touch:swipe.bottom="swipeHandler" v-touch-options="{swipeTolerance: 9999}">
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
    </div>
</template>

<script>
export default {
  name: 'VueSwipeTest',
  methods: {
    swipeHandler(e) {
      alert('swipe');
    }
  }
}
</script>

<style scoped>
  .swipe {
    background: red;
  }
</style>

When swiping down swipeHandler() will fire disregarding the swipeTolerance.

@Anders-Lunde
Copy link

I am also experiencing this bug: tolerance only affects X, not UY swipes. This is on iPad air 2, iPadOS 13.

@jerrybendy jerrybendy merged commit 135ddf6 into jerrybendy:master Dec 9, 2020
@jerrybendy
Copy link
Owner

I have forgotten this issue for a long time. Sorry about that.

Thanks for @cameronbatty 's contribution. I have merged this PR and release a new version of v3.0.1. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants