UNPKG

5.62 kBHTMLView Raw
1<!DOCTYPE html>
2<html ng-app="myApp">
3<head>
4 <meta charset="UTF-8" />
5 <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
6 <title>Angular.js Container Scroll Example</title>
7 <meta name="viewport" content="width=device-width, initial-scale=1.0">
8 <style type="text/css">
9 html, body {
10 margin: 0;
11 padding: 0;
12 background: #ebebeb;
13 }
14 body, button {
15 font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
16 }
17
18 h1 {
19 padding-top: 50px;
20 }
21 img {
22 max-width: 100%;
23 }
24 nav {
25 position: fixed;
26 z-index: 1;
27 top: 0;
28 left: 0;
29 right: 0;
30 background: #fff;
31 background: rgba(255, 255, 255, 0.8);
32 }
33 nav li, nav ul {
34 list-style: none;
35 margin: 0;
36 padding: 0;
37 text-align: center
38 }
39 nav li, nav a {
40 display: inline-block;
41 }
42 nav a {
43 padding: 20px;
44 color: #333;
45 text-decoration: none;
46 }
47 a:hover {
48 background: #fff;
49 }
50 a.active {
51 background: #00AC7F;
52 color: #fff;
53 }
54 .wrap {
55 position: relative;
56 max-width: 1000px;
57 margin: 0 auto;
58 padding: 50px 20px;
59 }
60 section {
61 padding: 20px 0 20px 0;
62 margin-bottom: 30px;
63 }
64 footer {
65 text-align: center;
66 }
67 button {
68 font-size: 18px;
69 border: 0;
70 padding: 15px 30px;
71 background: #00AC7F;
72 color: #fff;
73 cursor: pointer;
74 }
75
76 #container {
77 overflow: auto;
78 height: 400px;
79 padding: 0;
80 margin: 10px 0 20px 0;
81 }
82
83 </style>
84</head>
85<body>
86<div class="wrap" ng-controller="MyCtrl">
87 <nav du-scroll-container="container">
88 <ul>
89 <li><a href="#section-1" du-smooth-scroll du-scrollspy>Section 1</a></li>
90 <li><a href="#section-2" du-smooth-scroll du-scrollspy>Section 2</a></li>
91 <li><a href="#section-3" du-smooth-scroll du-scrollspy>Section 3</a></li>
92 <li><a href="http://github.com/oblador/angular-scroll/">Project on Github</a></li>
93 </ul>
94 </nav>
95 <h1>Angular.js Container Scroll Example</h1>
96 <div id="container" du-scroll-container>
97 <section id="section-1">
98 <h2>Section 1</h2>
99 <p><a href="#section-4" du-smooth-scroll>To section 4</a> Bacon ipsum dolor sit amet sausage tail capicola ground round hamburger ham hock. Short ribs pig andouille meatball, pastrami tri-tip fatback ham hock shank kielbasa swine. Rump pancetta jerky kielbasa doner beef ribs tongue hamburger strip steak drumstick andouille shoulder shank flank. Swine drumstick meatball pig beef sausage strip steak.</p>
100
101 <img src="http://lorempixel.com/1000/500/" alt="" />
102 </section>
103
104 <section id="section-2">
105 <h2>Section 2</h2>
106 <p>Bacon strip steak ground round, tongue pastrami short ribs pork chop venison turducken sausage sirloin. Flank chicken pork chop capicola turkey turducken cow pork loin biltong meatball drumstick pancetta filet mignon ground round fatback. Ham hock jerky short ribs brisket. Meatloaf shoulder pork chop capicola, sirloin swine pig pork. Jerky ribeye hamburger pork loin sirloin kevin bresaola boudin chuck flank. Ham hock pork belly chicken jerky rump bresaola.</p>
107 </section>
108
109 <section id="section-3">
110 <h2>Section 3</h2>
111 <p>Shank fatback pastrami short loin, turkey jowl kielbasa ribeye chicken jerky drumstick flank ham. Swine shankle pork belly kielbasa shoulder flank jowl, sirloin doner. Kevin tri-tip bresaola leberkas. Swine ball tip cow strip steak. Ham filet mignon pork chop, pork fatback andouille pork loin shoulder jowl swine strip steak turducken prosciutto rump.</p>
112
113 <img src="http://lorempixel.com/1000/400/" alt="" />
114
115 <p>Tongue tri-tip pastrami, shoulder rump pork belly ground round. Ham hock chuck leberkas doner, strip steak corned beef tri-tip capicola. Rump turkey ham sausage shankle. Flank shankle pork chop ham hock. Shankle venison kielbasa, pancetta swine beef ball tip t-bone bacon hamburger ground round ribeye flank. Turducken bacon bresaola, chicken kevin boudin ball tip strip steak filet mignon pork turkey shank ground round. Kielbasa fatback prosciutto pork chop, jerky ground round leberkas boudin ball tip beef shankle shoulder swine brisket. </p>
116 </section>
117
118 <section id="section-4">
119 <h2>Section 4</h2>
120 <img src="http://lorempixel.com/1000/600/" alt="" />
121
122 <p><a href="#section-1" du-smooth-scroll>To section 1</a> Shoulder cow tenderloin chuck, pork chop jerky doner leberkas. Chuck sausage hamburger, kevin beef pork chop pork shoulder ground round ball tip turducken flank. Bresaola tri-tip meatloaf, salami venison tail pig shank shankle jowl sausage brisket cow biltong turducken. Swine turducken hamburger ball tip short loin prosciutto kevin jowl tri-tip. Doner meatloaf pork brisket.</p>
123 </section>
124 </div>
125 <footer>
126 <button ng-click="toTheTop()">To the top!</button> or <button ng-click="toSection2()">To section 2</button>
127 </footer>
128</div>
129
130<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
131<script src="../angular-scroll.js"></script>
132<script>
133angular.module('myApp', ['duScroll']).
134 controller('MyCtrl', function($scope){
135 var container = angular.element(document.getElementById('container'));
136 var section2 = angular.element(document.getElementById('section-2'));
137
138 $scope.toTheTop = function() {
139 container.scrollTop(0, 5000);
140 }
141
142 $scope.toSection2 = function() {
143 container.scrollTo(section2, 0, 1000);
144 }
145 }
146);
147</script>
148</body>
149</html>