touchstart: //手指放到屏幕上时触发vue
touchmove: //手指在屏幕上滑动时触发git
touchend: //手指离开屏幕时触发github
在touchmove事件回调中动态设置容器的transform中的translate3d属性,以达到tab随滑动而移动的效果bash
即在tab滑动超出必定阈值时释放,tab自动切换dom
推荐手机访问ui
详见个人githubspa
<div class="touch-flipbook" ref="touchCon" @touchstart.prevent="TouchStart" @touchmove.prevent="TouchMove"
@touchend="TouchEnd">
<div class="page p0">
<!-- /* page有先后两面 */ -->
<div class="front">0正</div>
<div class="back">0反</div>
</div>
<!-- /* page2为翻页以后显示的*/ -->
<div class="page p1">
<div class="front">1正</div>
<div class="back">1反</div>
</div>
<div class="page p2">
<div class="front">2正</div>
<div class="back">2反</div>
</div>
</div>
复制代码
touch事件的处理与上述滑动Tab的处理方式大体相同,不一样在于3d
此处需动态设置为transform中的rotate属性。code
须要注意的有如下几点:orm
scaleY(1)
来解决镜像问题。