以iscroll 為例修改
me.addEvent = function(el, type, fn, capture) {
// el.addEventListener(type, fn, !!capture) 改為
el.addEventListener(type, fn, { passive: false })
}
me.addEvent = function(el, type, fn, capture) {
// el.addEventListener(type, fn, !!capture) 改為
el.addEventListener(type, fn, { passive: false })
}
<div class="wrapper">
<div class='header'></div>
<div id='myContent' class="content">
<div class='scroller'><div class='itemContainer'></div></div>
</div>
<div class="footer"></div>
</div>
要scroll的內容下需有一個唯一的子節點(div或ul都可),iScroll會對這個div做scroll.wrapper{
position:absolute;z-index:1;//以絕對位置設定當作最下層layer
top:0;left:0;//設定貼在browser的最左上方
margin:0;padding:0;
width:300px;//可以用%設定
height:300px;
}
4.header .header{
position:absolute;z-index:3;//設定在最上層
top:0;left:0;//設定貼在wrapper的靠左上方
margin:0;padding:0;
width:100%;//設定與wrapper相同寬度
height:50px;//設定header的絕對高度
}
5.footer.footer{
position:absolute;z-index:3;//設定在最上層
bottom:0px;left:0;//設定貼在wrapper的靠左下方
margin:0;padding:0;
width:100%;//設定與wrapper相同寬度
height:50px;//設定header的絕對高度
}
6.content.content{
position:absolute;z-index:2;//設定在中間層
top:50px;//設定在header的下方,也就是設定header的高度
left:0;
margin:0;padding:0;
width:100%;
height:200px;//設定wrapper扣掉header與footer後的高度,這部份由js動態改變值
overflow:auto;//設定內部的所有內容在超過的時候以scroll顯示
>.scroller{
width:100%;//注意千萬不要設定height,內容超過時才可以scroll
>.itemContainer{
width:100%;//注意千萬不要設定height,內容超過時才可以scroll
}
}
}
window.scroll=new iScroll('myContent',{
hScrollBar:false,
vScrollBar:true,
hideScrollBar:false
})
2.refreshsetTimeout(function(){
window.scroll.refresh();
},0)
