KevinBatdorf / liquidslider

A Responsive jQuery Content Slider
161 stars 63 forks source link

previous/next panel feature #116

Closed xelakz closed 9 years ago

xelakz commented 10 years ago

Can we have another feature where if end of panel and you use swipe to the right, instead of going back to the first panel, it will just stop? or vice versa(if you swipe to the left from the first panel, going to the last panel has be disabled). regardless if a configuration of continue: true/false

KevinBatdorf commented 10 years ago

I havent tested it in a long time, but you shouldn't have a problem overriding the swipe arguments in the settings:

swipeArgs: {
    fallbackToMouseEvents: false,
    allowPageScroll: 'vertical',
    swipe: function(e, dir) {
      if (dir === 'up' || dir === 'down') return false;

     // This is new
     var nextP = this.(sanatizePanel(this.nextPanel))
     if (nextP === 1 || nextP === this.panelCount) return false;

      // Reverse the swipe direction
      this.swipeDir = (dir === 'left') ? 'right' : 'left';
      this.setNextPanel(this.swipeDir);
    }
}

this might not work as expected though, but mess around with it a bit and let me know. Also note that i misspelled "sanitize" as sanatize, which will be corrected in the next version