zepto移动端上下滑动 怎么做

html-css015

zepto移动端上下滑动 怎么做,第1张

手机端页面切换,页面跟随手势上下/左右滑动,依赖zepto.js。如果工程中同时使用jquery的话,采用如下方式来调用zepto的方法。

(function($){$('#Marke').touchSlider({direction: 'v',itemSelector:'.slide',slidePercent:0.2})

})(Zepto)。

调用方式:$('#Marke').touchSlider({direction: 'v',itemSelector:'.slide',slidePercent:0.2})

direction:v/h,竖滑或横滑。

itemSelector:需要滑动的一组DOM元素,使用同一的className来标识。

slidePercent:用户滑动多少百分比(0.0~1.0)后才会触发slider,否则就还原到滑动前的位置。

扩展资料:

zepto的使用:

1,针对移动端程序,Zepto有一些基本的触摸事件可以用来做触摸屏交互。

2,DOM操作:,添加id时Zepto会生效。

3,事件触发:使用zepto时load事件的处理函数会执行。

4,事件委托:zepto中,选择器上所有的委托事件都依次放入到一个队列中。

5,width() 与 height():zepto由盒模型(box-sizing)决定,用.width()返回赋值的width,用.css('width')返回border等的结果。

//增加代码

$(document).swipeLeft(function(){

if (isAnimating) return

last.row = now.row

last.col = now.col

if (last.row>2 &&last.row<4 &&last.col==2) { now.row = last.rownow.col = 3pageMove(towards.left)}

})

$(document).swipeLeft(function(){

if (isAnimating) return

last.row = now.row

last.col = now.col

if (last.row>2 &&last.row<4 &&last.col==3) { now.row = last.rownow.col = 4pageMove(towards.left)}

})

$(document).swipeRight(function(){

if (isAnimating) return

last.row = now.row

last.col = now.col

if (last.row>2 &&last.row<4 &&last.col==4) { now.row = last.rownow.col = 3pageMove(towards.right)}

})

$(document).swipeRight(function(){

if (isAnimating) return

last.row = now.row

last.col = now.col

if (last.row>2 &&last.row<4 &&last.col==3) { now.row = last.rownow.col = 2pageMove(towards.right)}

})