Eti*_*tin 42 javascript css css3 ios scroll-snap-points
我注意到iOS 10中有一个带有CSS scroll-snap属性的奇怪错误.
这是我的css:
#springBoard{
height: 100%;
width: 100%;
font-size: 0px;
white-space: nowrap;
overflow: scroll;
-webkit-overflow-scrolling: touch;
-webkit-scroll-snap-type: mandatory;
-webkit-scroll-snap-points-x: repeat(100%);
}
section{
display: inline-block;
width: 100%;
height: 100%;
vertical-align: top;
font-size: 16px;
}
Run Code Online (Sandbox Code Playgroud)
如果我以编程方式滚动到捕捉点,然后更改滚动捕捉容器内的内容,导航将捕捉到第一个捕捉点.
// Programatically scroll the scroll-snap container
$("#springBoard")[0].scrollLeft = 320
Run Code Online (Sandbox Code Playgroud)
它似乎与我触发滚动的方式无关.所有这些滚动方法都会产生相同的结果:
$("#springBoard")[0].scrollLeft = 320
$("#springBoard").animate({scrollLeft: 320}, 1)
$("#springBoard > section:eq(1)")[0].scrollIntoView()
window.location.hash = "sectionId"
Run Code Online (Sandbox Code Playgroud)
我花了几天时间试图解决这个问题但到目前为止没有成功.
有没有人知道绕过这个小智 -2
请尝试这样:
$('#springBoard').animate({scrollLeft: $('#springBoard').position().left + 320},1 );
Run Code Online (Sandbox Code Playgroud)