First test of iScroll5
by deanpeters
HTML
<script src="http://beanerspace.com/scripts/iscroll5.js"></script>
<script src="http://beanerspace.com/scripts/zepto.js"></script>
<script src="http://beanerspace.com/scripts/deferred.min.js"></script>
<script src="http://beanerspace.com/scripts/fx_methods.js"></script>
<script src="http://beanerspace.com/scripts/touch.js"></script>
<div id="header">iScroll</div>
<div id="wrapper">
<div id="scroller">
<ul id="first-list" class="pretty-list">
<li><strong>First List</strong>
</li>
<li>Pretty row
<img src="http://placehold.it/40x32/116622/e8e8e8.png&text=Image%2002" />
</li>
<li>Pretty row
<img src="http://placehold.it/40x33/227744/e8e8e8.png&text=Image%2003" />
</li>
<li>Pretty row
<img src="http://placehold.it/40x34/200644/e8e8e8.png&text=Image%2004" />
</li>
<li>Pretty row
<img src="http://placehold.it/40x35/446677/e8e8e8.png&text=Image%2005" />
</li>
<li>Pretty row
<img src="http://placehold.it/40x36/217646/e8e8e8.png&text=Image%2006" />
</li>
<li>Pretty row
<img src="http://placehold.it/40x37/126774/e8e8e8.png&text=Image%2007" />
</li>
<li>Pretty row
<img src="http://placehold.it/40x38/217648/e8e8e8.png&text=Image%2008" />
</li>
<li>Pretty row
<img src="http://placehold.it/40x39/764921/e8e8e8.png&text=Image%2009" />
</li>
<li>Pretty row
<img src="http://placehold.it/41x30/217640/e8e8e8.png&text=Image%2010" />
</li>
<li>Pretty row
<img src="http://placehold.it/41x31/641217/e8e8e8.png&text=Image%2011" />
</li>
<li>Pretty row
<img...
CSS
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html {
-ms-touch-action: none;
}
body, ul, li {
padding: 0;
margin: 0;
border: 0;
}
body {
font-size: 12px;
font-family: ubuntu, helvetica, arial;
overflow: hidden;
/* this is important to prevent the whole page to bounce */
}
#header {
position: absolute;
z-index: 2;
top: 0;
left: 0;
width: 100%;
height: 45px;
line-height: 45px;
background: #CD235C;
padding: 0;
color: #eee;
font-size: 20px;
text-align: center;
font-weight: bold;
}
#footer {
position: absolute;
z-index: 2;
bottom: 0;
left: 0;
width: 100%;
height: 48px;
background: #444;
padding: 0;
border-top: 1px solid #444;
}
#wrapper {
position: absolute;
z-index: 1;
top: 45px;
bottom: 48px;
left: 0;
width: 100%;
background: #ccc;
overflow: hidden;
}
#scroller {
position: absolute;
z-index: 1;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
width: 100%;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
transform: translateZ(0);
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-text-size-adjust: none;
-moz-text-size-adjust: none;
-ms-text-size-adjust: none;
-o-text-size-adjust: none;
text-size-adjust: none;
}
#scroller ul {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
text-align: left;
}
#scroller li {
padding: 0 10px;
height: 40px;
line-height: 40px;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
background-color: #fafafa;
font-size: 14px;
}
#second-list, #third-list, #fourth-list {
display:none;
}
}
JavaScript
$( "#scroller" ).swipeLeft(function() {
console.log("Left swipe");
});
$( "#scroller" ).swipeRight(function() {
console.log("swipe Right");
});
var myScroll;
myScroll = new iScroll('#wrapper', {
mouseWheel: true,
// scrollX: true,
// eventPassthrough: true,
// preventDefault: true
});
// document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);