Last active
August 29, 2015 14:05
-
-
Save mrjman/0d0b08cb1f239d0d3c75 to your computer and use it in GitHub Desktop.
jquery.scroll-nav plugin - scrolls to anchor on page and keeps track of active nav link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html class="no-js"> | |
<head> | |
<style> | |
a:hover { | |
color: green; | |
} | |
li.active { | |
color: red; | |
} | |
div { | |
border: 1px solid red; | |
height: 300px; | |
margin-bottom: 30px; | |
} | |
.nav { | |
position: fixed; | |
} | |
</style> | |
</head> | |
<body> | |
<ul class="nav"> | |
<li><a href="#one">One</a></li> | |
<li><a href="#two">Two</a></li> | |
<li><a href="#three">Three</a></li> | |
<li><a href="#four">Four</a></li> | |
<li><a href="#five">Five</a></li> | |
<li><a href="#six">Six</a></li> | |
<li><a href="#seven">Seven</a></li> | |
</ul> | |
<div id="one">One</div> | |
<div id="two">Two</div> | |
<div id="three">Three</div> | |
<div id="four">Four</div> | |
<div id="five">Five</div> | |
<div id="six">Six</div> | |
<div id="seven">Seven</div> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script src="scripts/jquery-ui.js"></script> | |
<script src="scripts/jquery.scroll-nav.js"></script> | |
<script src="scripts/main.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($) { | |
$('.nav').scrollNav({ | |
'duration': 1000, | |
'easing': 'easeOutQuad' // can use any default easing, or include jquery-ui easing to get more options | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment