$.fn.pageSlider = function (){ var _this = this ; var _len = _this.length; var currentIndex = 0; _this.each( function (idx,ele){ var zIndex = (_len - idx) * 10; $(ele).css({ width: "100%" , height: "100%" , position: "absolute" , zIndex: zIndex, "transition-duration" : "700ms" , "-webkit-transition-duration" : "700ms" , "-webkit-animation-timing-function" : "ease-in-out" }); }); _this.on( "swipeUp" , function (){ //next if (currentIndex < _len - 1){ _this.eq(currentIndex).css({ "-webkit-transform" : "translateY(-100%)" , "transform" : "translateY(-100%)" }); _this.eq(currentIndex).trigger( "leave" ); _this.eq(currentIndex+1).css({ "-webkit-transform" : "translateY(0)" , "transform" : "translateY(0)" }); _this.eq(currentIndex+1).trigger( "enter" ); currentIndex ++; } }); _this.on( "swipeDown" , function (){ //prev if (currentIndex > 0){ _this.eq(currentIndex-1).css({ "-webkit-transform" : "translateY(0)" , "transform" : "translateY(0)" }); _this.eq(currentIndex-1).trigger( "enter" ); _this.eq(currentIndex).trigger( "leave" ); currentIndex --; } }); } |