iScroll + AngularJS
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<script src="http://cubiq.org/dropbox/iscroll4/src/iscroll.js"></script>
<div ng-controller="MyCtrl">
<button ng-click="addContent()">Add more content</button>
<div id="header"><a href="http://cubiq.org/iscroll">iScroll</a></div>
<div id="wrapper">
<div id="scroller" iscroll-watcher>
<div id="thelist" ng-bind-html-unsafe="content"></div>
<!-- <ul id='thelist'>
<li ng-repeat="item in list">Item {{$index + 1}}</li>
</ul> -->
</div>
</div>
<div id="footer"></div>
</div>
CSS
body,ul,li {
padding:0;
margin:0;
border:0;
}
#thelist { font-size: 30px;}
body {
font-size:12px;
-webkit-user-select:none;
-webkit-text-size-adjust:none;
font-family:helvetica;
}
#header {
position:absolute; z-index:2;
top:10; left:0;
width:100%;
height:45px;
line-height:45px;
background-color:#d51875;
background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #fe96c9), color-stop(0.05, #d51875), color-stop(1, #7b0a2e));
background-image:-moz-linear-gradient(top, #fe96c9, #d51875 5%, #7b0a2e);
background-image:-o-linear-gradient(top, #fe96c9, #d51875 5%, #7b0a2e);
padding:0;
color:#eee;
font-size:20px;
text-align:center;
}
#header a {
color:#f3f3f3;
text-decoration:none;
font-weight:bold;
text-shadow:0 -1px 0 rgba(0,0,0,0.5);
}
#footer {
position:absolute; z-index:2;
bottom:0; left:0;
width:100%;
height:48px;
background-color:#222;
background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #999), color-stop(0.02, #666), color-stop(1, #222));
background-image:-moz-linear-gradient(top, #999, #666 2%, #222);
background-image:-o-linear-gradient(top, #999, #666 2%, #222);
padding:0;
border-top:1px solid #444;
}
#wrapper {
position:absolute; z-index:1;
top:70px; bottom:48px; left:0;
width:100%;
background:#aaa;
overflow:auto;
}
#scroller {
position:absolute; z-index:1;
/* -webkit-touch-callout:none;*/
-webkit-tap-highlight-color:rgba(0,0,0,0);
width:100%;
padding:0;
}
#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;
}
JavaScript
var myApp = angular.module('myApp',[]);
myApp.directive('iscrollWatcher', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var myScroll, id = element[0].getAttribute('id') || Date.now();
element[0].setAttribute('id', id);
document.getElementById(id).addEventListener(
'DOMContentLoaded',
setTimeout(function () {
myScroll = new iScroll('wrapper');
}, 0),
false
);
document.getElementById(id).addEventListener(
'DOMSubtreeModified',
function() {
myScroll.refresh();
},
false
);
}
};
});
function MyCtrl($scope) {
$scope.addContent = function() {
$('#thelist').html($('#thelist').html() + $scope.generateContent());
};
$scope.generateContent = function() {
return (new Array(100)).join("abcdefghijklmnopqrstuvwxyziloveyou ");
};
$scope.content = $scope.generateContent();
$scope.list = new Array(100);
}