Navigation ScrollSpy Smooth Scroll - Download Navigation ScrollSpy & Smooth Scroll Plugin - nav-scroll-spy.js

Download Navigation ScrollSpy & Smooth Scroll Plugin – nav-scroll-spy.js

Posted on

This time I will share jQuery Plugin and tutorial about Navigation ScrollSpy & Smooth Scroll Plugin – nav-scroll-spy.js, hope it will help you in programming stack.

Navigation ScrollSpy Smooth Scroll - Download Navigation ScrollSpy & Smooth Scroll Plugin - nav-scroll-spy.js
File Size: 11.9 KB
Views Total: 4709
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A small yet useful jQuery scrollspy and smooth scroll plugin for site navigation that allows you to highlight the active item in the menu and smoothly scroll through the webpage.

Features:

  • Highlights menu items to indicate the page section you are currently looking at. 
  • Smoothly scroll the page to sections as you click the menu items.

How to use it:

1. Create the site navigation and page sections as follows:

01 <ul class="nav-group">
02   <li class="nav-item active">Item 1</li>
03   <li class="nav-item">Item 2</li>
04   <li class="nav-item">Item 3</li>
05   ...
06 </ul>
07  
08 <div class="container">
09   <div class="spy-item">Section 1</div>
10   <div class="spy-item">Section 2</div>
11   <div class="spy-item">Section 3</div>
12   ...
13 </ul>

2. Load the main JavaScript file jq.nav-scroll-spy.js after the latest jQuery library.

2         integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT"
3         crossorigin="anonymous"></script>
4 <script src="jq.nav-scroll-spy.js"></script>

3. Call the function and the plugin will do the rest.

1 $(document).jqNav<a href="https://www.jqueryscript.net/tags.php?/Scroll/">Scroll</a>Spy();

4. Change the default duration of the smooth scroll animation.

1 $(document).jqNavScrollSpy({
2   speed: 550 // in ms
3 });

5. Override the default easing effect. For more easing functions, load jQuery easing plugin or jQuery UI library in your document.

1 $(document).jqNavScrollSpy({
2   easing: 'easeInOutBack' // default 'swing'
3 });

6. Default selectors.

1 $(document).jqNavScrollSpy({
2   navItems: '.nav-item',
3   scrollContainer: 'html,body',
4   spyItems: '.spy-item'
5 });

7. Apply your own CSS styles to the active menu item.

1 .nav-item.active{
2   background-color: #222;
3   color: #fff;
4 }

This awesome jQuery plugin is developed by huxinmin. For more Advanced Usages, please check the demo page or visit the official website.

source : jquery.net