Skip to content

Commit

Permalink
no resistance for 3d slider
Browse files Browse the repository at this point in the history
  • Loading branch information
max-power committed Dec 10, 2012
1 parent 6193b8c commit 4ad9659
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions swipeslide.js
Expand Up @@ -119,14 +119,8 @@ SwipeSlide.prototype = {

touchMove: function(e){
if (!this.touch.start) return

this.touch.end = this.trackTouch(e)
var distance = this.distance()
//add some resistance if first or last slide
if (this.isFirst() && distance > 0 || this.isLast() && distance < 0) {
distance /= 1 + Math.abs(distance) / this.dimension
}
this.move(distance, 0)
this.move(this.distanceWithResistance(), 0)
return false
},

Expand All @@ -151,6 +145,12 @@ SwipeSlide.prototype = {
try { return this.touch.end[d] - this.touch.start[d] } catch(e) { return 0 }
},

distanceWithResistance: function(){
var d = this.distance()
if (this.isFirst() && d > 0 || this.isLast() && d < 0) d /= (1 + Math.abs(d) / this.dimension)
return d
},

callback: function(){
// call user defined callback function with the currentPage number and an array of visible slides
if ($.isFunction(this.options.onChange)) this.options.onChange(this, this.currentPage, this.visibleSlides())
Expand Down Expand Up @@ -211,7 +211,8 @@ $.extend(SwipeSlide3D.prototype, {
},
vectorsWithDeg: function(degree){
return (this.isVertical ? '1,0' : '0,1') + ',0,' + degree + 'deg'
}
},
distanceWithResistance: function() {return this.distance()} // no resistance for 3d
})

// zepto plugin
Expand Down

0 comments on commit 4ad9659

Please sign in to comment.