forked from inorganik/angular-scroll-spy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
87 lines (70 loc) · 5.55 KB
/
index.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
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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="robots" content="index,follow">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="A javascript class that animates a numerical value by counting to it.">
<title>angular-scroll-spy.js</title>
<link rel="stylesheet" type="text/css" href="../inorganik.github.io/assets/css/style.css?v=20140820">
<!--<link rel="stylesheet" type="text/css" href="../assets/css/style.css?v=20141210">-->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"></script>
<script type="text/javascript" src="angular-scroll-spy.js"></script>
<script type="text/javascript" src="../countUp.js/countUp.js"></script>
<script type="text/javascript" src="../countUp.js/angular-countUp.js"></script>
<script type="text/javascript">
var app = angular.module("demoApp",["scrollSpyModule", "countUpModule"]);
// google analytics
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-7742845-9', 'inorganik.github.io');
ga('send', 'pageview');
</script>
</head>
<body ng-app="demoApp">
<a class="forkMe" href="https://github.com/inorganik/angular-scroll-spy"><img src="../assets/img/forkme_custom_indigo.png" alt="Fork me on GitHub"></a>
<div id="wrap">
<header>
<div id="github"><a class="block" href="https://github.com/inorganik"></a></div>
<div class="leaderLine">////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////</div>
<div id="logo"><a class="block" href="http://inorganik.github.io"></a></div>
</header>
<section>
<h1>angular-scroll-spy.js <small id="version" class="lt-gray"></small></h1>
<p>A simple, lightweight scroll-spy directive for angular that was built from scratch. It broadcasts events as elements are scrolled into or out of view.</p>
<h3 class="marginTop marginBottom"><a class="lime weight700" href="https://github.com/inorganik/angular-scroll-spy">Download on Github</a></h3>
<ul>
<li><code class="indigo">'elementFirstScrolledIntoView'</code> is fired once when the element first scrolls into view</li>
<li><code class="indigo">'elementScrolledIntoView'</code> is fired every time the element scrolls into view</li>
<li><code class="indigo">'elementScrolledOutOfView'</code> is fired every time the element is scrolled out of view</li>
</ul>
<p>Add the <code class="indigo">scroll-spy</code> attribute on the element you want to receive a scroll event for. Then in your controller, you can respond to events like this:</p>
<div class="code-contain marginBottom indigo">
<code id="codeVisualizer" class="indigo">$scope.$on('elementFirstScrolledIntoView', function (event, data) {<br>
  if (data === 'myElementId') {<br>
    // do something<br>
  }<br>
});
</code>
</div>
<p>The code above requires you to have an id assigned to the element you use scroll-spy with, because then you can have multiple elements on a page with scroll-spy. If you just have one, you can remove the if statement in the event handler.</p>
<p>For this demo, <a href="http://inorganik.github.io/countUp.js/">CountUp.js</a> is being used to show a counting animation when the scroll event has fired. The angular countUp module included in that repo uses the `scroll-spy-event` attribute to fire on that event if the attribute is present.</p>
<p class="indigo large">Scroll down...</p>
<div class="scroll-down"><div> </div></div>
<div style="height:850px"> </div>
<p>The <a href="https://github.com/inorganik/CountUp.js">countUp</a> animation below is listening for <b>'elementScrolledIntoView'</b> and will fire <b>every time</b> it's scrolled into view.</p>
<h1 class="kindaBig" count-up id="animation1" start-val="0" end-val="2536.1" duration="2.5" decimals="1" scroll-spy-event="elementScrolledIntoView" scroll-spy></h1>
<div style="height:850px"> </div>
<p>The <a href="https://github.com/inorganik/CountUp.js">countUp</a> animation below is listening for <b>'elementFirstScrolledIntoView'</b> and will <b>only fire once.</b></p>
<h1 class="kindaBig" count-up id="animation2" start-val="0" end-val="15485" duration="2.5" scroll-spy-event="elementFirstScrolledIntoView" scroll-spy></h1>
<div style="height:850px"> </div>
<p>Here's another <b>'elementScrolledIntoView'</b>.</p>
<h1 class="kindaBig" count-up id="animation3" start-val="0" end-val="6387.42" duration="2.5" decimals="2" scroll-spy-event="elementScrolledIntoView" scroll-spy></h1>
<div style="height:200px"> </div>
</section>
</div>
</body>
</html>