forked from Luegg/angularjs-scroll-glue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
58 lines (48 loc) · 1.36 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<title>AngularJS Scroll Glue Directive</title>
<style type="text/css">
[scroll-glue]{
height: 100px;
overflow-y: scroll;
border: 1px solid red;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.js"></script>
<script src="src/scrollglue.js"></script>
<script>
angular.module('demo', ['luegg.directives']);
function ItemsCtrl($scope, $timeout){
$scope.items = ['1', '2', '3'];
$scope.glued = true;
function addItem(){
$scope.items.push(Math.random());
$timeout(addItem, 1000);
}
$timeout(addItem, 1000);
}
</script>
</head>
<body ng-app="demo" ng-controller="ItemsCtrl">
<h1>Simple</h1>
<div scroll-glue>
<ul>
<li ng-repeat="item in items">{{item}}</li>
</ul>
</div>
<h1>With data binding</h1>
<div scroll-glue ng-model="glued">
<ul>
<li ng-repeat="item in items">{{item}}</li>
</ul>
</div>
<a ng-click="glued = !glued">Toggle scroll-glue ({{glued}})</a>
<ol>
<li>Watch the element scrolling</li>
<li>Scroll up to release the glue</li>
<li>Scroll to bottom to attach the glue again</li>
</ol>
</body>
</html>