关于IScroll.js的snap出现的问题
IScroll.js的snap出现的问题 版本IScroll.js v5.2.0
创建IScroll,配置中加上 snap ,startX:-200 想要实现第二页为首页,左右滚动切页的效果。
但在初次打开html页面,设置好的第二页首页上,横向x拖动时情况正常。但如果在当前页面不小心误操作纵向y拖动时,它就会特别离奇的从设置好的第二页首页(-200)自动返回到到第一页(0)的位置上。
请问如何解决
附上代码
.box {
position: relative;
width: 200px;
height: 300px;
overflow: hidden;
margin: 0 auto;
}
.Content {
width: 1600px;
height: 300px;
}
.Contentitem {
width: 200px;
height: 300px;
box-sizing: border-box;
border: 1px solid #000;
float: left;
}
let myiscroll = new IScroll('.box', {
startX: -200,
scrollX: true,
snap: '.Contentitem',
})
<div class="box">
<div class="Content">
<div class="Contentitem" style="background-color: #f3f4f3;">00</div>
<div class="Contentitem">-200首页</div>
<div class="Contentitem" style="background-color: #f3f4f3;">400</div>
<div class="Contentitem">600</div>
<div class="Contentitem" style="background-color: #f3f4f3;">800</div>
<div class="Contentitem">1000</div>
<div class="Contentitem" style="background-color: #f3f4f3;">1200</div>
<div class="Contentitem">1400</div>
</div>
</div>
另外还遇到因设置了snap后,无法通过 ele.style.transform=translate(-200px)
修改当前滚动元素的偏移(发现会被snap覆盖)