-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrollTo.js
36 lines (33 loc) · 1.57 KB
/
scrollTo.js
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
// <ul>
// <li><a href="" scroll-to="section1">Section 1</a></li>
// <li><a href="" scroll-to="section2">Section 2</a></li>
// </ul>
// <h1 id="section1">Hi, I'm section 1</h1>
// <p>
// Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis.
// Summus brains sit, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris.
// Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium.
// Nescio brains an Undead zombies. Sicut malus putrid voodoo horror. Nigh tofth eliv ingdead.
// </p>
// <h1 id="section2">I'm totally section 2</h1>
// <p>
// Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis.
// Summus brains sit, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris.
// Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium.
// Nescio brains an Undead zombies. Sicut malus putrid voodoo horror. Nigh tofth eliv ingdead.
// </p>
//
angular.module("scrollTo",[])
.directive('scrollTo', function ($location, $anchorScroll) {
return function(scope, element, attrs) {
element.bind('click', function(event) {
event.stopPropagation();
scope.$on('$locationChangeStart', function(ev) {
ev.preventDefault();
});
var location = attrs.scrollTo;
$location.hash(location);
$anchorScroll();
});
}
});