This time I will share jQuery Plugin and tutorial about Single Page Navigation With Scrollspy – jQuery NavPoints, hope it will help you in programming stack.
The NavPoints jQuery plugin helps developers to create a sticky navigation for single page web apps, with support for smooth scroll, active highlighting and hash change.
How to use it:
1. Create the html for the single page navigation containing anchor links that point to different sections within the document.
02 |
< div class = "container" > |
04 |
< a href = "#section1" class = "active" >Section 1</ a > |
05 |
< a href = "#section2" >Section 2</ a > |
06 |
< a href = "#section3" >Section 3</ a > |
11 |
< section id = "section1" > |
15 |
<section id = "section2" > |
19 |
<section id = "section3" > |
2. The example CSS for the single page navigation.
04 |
background-color : #333 ; |
16 |
text-decoration : none ; |
21 |
background-color : #ddd ; |
3. Highlight the active menu items when you scroll through page sections.
2 |
background-color : #4caf50 ; |
4. Import jQuery JavaScript library and the jQuery NavPoints plugin into the document.
1 |
< script src = "/path/to/jquery.min.js" ></ script > |
2 |
< script src = "/path/to/jquery.navpoints.min.js" ></ script > |
5. Attach the plugin to the single page navigation on document ready. Done.
2 |
$( '#navigation' ).navpoints(); |
6. Customize the animation speed when smoothly scrolling through page sections. Default: 300ms.
1 |
$( '#navigation' ).navpoints({ |
7. Specify how far down the page section is from the top after scrolling. Default: 0.
1 |
$( '#navigation' ).navpoints({ |
8. Customize the active class. Default: ‘active’.
1 |
$( '#navigation' ).navpoints({ |
9. Determine whether to update the URL hash on scroll. Default: false.
1 |
$( '#navigation' ).navpoints({ |
10. Determine whether to apply the active class to the parent container rather than nav links. Default: false.
1 |
$( '#navigation' ).navpoints({ |
This awesome jQuery plugin is developed by Ins-V. For more Advanced Usages, please check the demo page or visit the official website.