1 /** 2 * @class 3 */ 4 function Slider(view, callback, time, distance) { 5 Animation.call(this, view, callback, time); 6 this.slideStart = view.getX(); 7 this.slideDistance = distance; 8 } 9 10 Slider.prototype = new Animation(); 11 12 Slider.prototype.step = function(pos) { 13 var newX = (this.slideStart - 14 (this.slideDistance * 15 //cos will go from 1 to -1, we want to go from 0 to 1 16 ((-0.5 * Math.cos(pos * Math.PI)) + 0.5))) | 0; 17 18 newX = Math.max(Math.min(this.subject.maxLeft - this.subject.offset, newX), 19 this.subject.minLeft - this.subject.offset); 20 this.subject.setX(newX); 21 }; 22