forked from thenikso/angular-inview
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontainer.html
More file actions
89 lines (81 loc) · 2.37 KB
/
container.html
File metadata and controls
89 lines (81 loc) · 2.37 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="basicApp">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>angular-inview container example</title>
<style type="text/css">
html, body {
height: 100%;
}
#hud {
background: white;
border: 1px solid gray;
bottom: 0;
margin: 20px;
min-width: 220px;
position: fixed;
right: 0;
top: 0;
width: 25%;
overflow: auto;
}
#container {
height: 50%;
border: 3px solid black;
overflow: auto;
}
.lines {
list-style: none;
margin: 0;
padding: 0;
}
.lines li {
height: 100px;
}
.lines li:nth-child(odd) {
background-color: lightgray;
}
</style>
</head>
<body ng-controller="basicCtrl">
<div id="hud">
<ul>
<li ng-repeat="l in inviewLogs" ng-bind-html="l.message"></li>
</ul>
</div>
<div id="container" in-view-container>
<ul class="lines">
<li ng-repeat="t in testLines" in-view="containerLineInView($index, $inview, $inviewpart)">This is test contained-line #{{$index}}</li>
</ul>
</div>
<ul class="lines">
<li ng-repeat="t in testLines" in-view="lineInView($index, $inview, $inviewpart)">This is test line #{{$index}}</li>
</ul>
<script src="../node_modules/angular/angular.js"></script>
<script src="../angular-inview.js"></script>
<script type="text/javascript">
angular.module('basicApp', ['angular-inview']).controller('basicCtrl', function basicCtrl ($scope, $sce) {
var logId = 0;
$scope.testLines = [];
for (var i = 20; i >= 0; i--) {
$scope.testLines.push(i);
};
$scope.inviewLogs = [];
$scope.lineInView = function(index, inview, inviewpart) {
var inViewReport = inview ? '<strong>enters</strong>' : '<strong>exit</strong>';
if (typeof(inviewpart) != 'undefined') {
inViewReport = '<strong>' + inviewpart + '</strong> part ' + inViewReport;
}
$scope.inviewLogs.unshift({ id: logId++, message: $sce.trustAsHtml('Line <em>#' + index + '</em>: ' + inViewReport) });
}
$scope.containerLineInView = function(index, inview, inviewpart) {
var inViewReport = inview ? '<strong>enters</strong>' : '<strong>exit</strong>';
if (typeof(inviewpart) != 'undefined') {
inViewReport = '<strong>' + inviewpart + '</strong> part ' + inViewReport;
}
$scope.inviewLogs.unshift({ id: logId++, message: $sce.trustAsHtml('Containerd line <em>#' + index + '</em>: ' + inViewReport) });
}
});
</script>
</body>
</html>