GeoloeG / iron-swipeable-pages

[Polymer 1.x] Element that enables switching between different pages by swiping gesture.
MIT License
49 stars 25 forks source link

swipeable-pages will not start the tracking when element have a left position > 0 #44

Closed dartpast closed 7 years ago

dartpast commented 8 years ago

Swipeable-pages will not start the tracking when the left position > 0, due to incorrect track.x value in _onTrack function. The x-value have to be relative to the elements position otherwise the edgeSwipeSensitivity-check will not accept the value.

<app-header-layout>
  <app-header>
    <app-toolbar>Test iron-swipeable-pages</app-toolbar>
  </app-header>
  <div class="layout horizontal">
    <div class="flex">Left column</div>
    <iron-swipeable-pages>
      <div>Page 1</div>
      <div>Page 2</div>
    </iron-swipeable-pages>
  </div>
</app-header-layout>

With a window width of 1000px the track.x value will be 500 or greater, and the this.offsetWidth value 500 making (track.x - track.dx) > this.offsetWidth - this.edgeSwipeSensitivity true most of the times.

Adding the line: track.x = track.x - this.getBoundingClientRect().left; after var track = event.detail; in the _onTrack function made the trick for me.

MeTaNoV commented 8 years ago

Hi @dartpast , thanks for spotting the bug! Are you eager to submit your solution as a PR, or do you prefer that I do it? Cheers, Pascal

dartpast commented 8 years ago

@MeTaNoV You can include it to your next release :)

MeTaNoV commented 7 years ago

@dartpast should be fixed by release 1.2.7? Can you confirm and re-open if not?