Easy jQuery Affix Scrollspy Reading Progress Plugin newsAffix - Download Easy jQuery Affix,Scrollspy And Reading Progress Plugin - newsAffix

Download Easy jQuery Affix,Scrollspy And Reading Progress Plugin – newsAffix

Posted on

This time I will share jQuery Plugin and tutorial about Easy jQuery Affix,Scrollspy And Reading Progress Plugin – newsAffix, hope it will help you in programming stack.

Easy jQuery Affix Scrollspy Reading Progress Plugin newsAffix - Download Easy jQuery Affix,Scrollspy And Reading Progress Plugin - newsAffix
File Size: 11.2 KB
Views Total: 1211
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

newsAffix is a simple-to-use jQuery affix / scrollspy / reading progress plugin used to generate a sticky header navigation & scroll progress indicator for your long web content.

Features:

  • Highlights the nav items when you you scroll past their content sections.
  • Displays a progress bar to indicate the reading progress of current content section.
  • Scrolls smoothly between content sections by clicking on the nav items.

How to use it:

1. Create content sections where you want to apply the newsAffix plugin.

01 <div id="targeted-wrapper" class="content">
02  
03   <section class="content__section">
04     <h2 class="content__title js-na-header-start" data-na-header="1">Header title 1</h2>
05     <p class="content__text">Section 1</p>
06  
07     <h3 class="content__subtitle">This is sub-title 1</h3>
08     <p class="content__text">Sub Section 1</p>
09   </section>
10  
11   <section class="content__section">
12     <h2 class="content__title" data-na-header="2">Header title 2</h2>
13     <p class="content__text">Section 2</p>
14  
15     <h3 class="content__subtitle">This is sub-title 2</h3>
16     <p class="content__text">Sub Section 2</p>
17   </section>
18  
19   <section class="content__section">
20     <h2 class="content__title" data-na-header="3">Header title 3</h2>
21     <p class="content__text">Section 3</p>
22  
23     <h3 class="content__subtitle">This is sub-title 3</h3>
24     <p class="content__text">Sub Section 3</p>
25   </section>
26  
27   <section class="content__section">
28     ...
29   </section>
30  
31 </div>

2. Load jQuery library and the jQuery newsAffix plugin at the end of the document.

1 <script src="//code.jquery.com/jquery.min.js"></script>
2 <script src="js/jquery.newsAffix.js"></script>

3. Initialize the plugin with default options.

1 $('body').newsAffix();

4. Let’s start to style the plugin as follows:

001 .news-affix {
002   position: fixed;
003   left: 0;
004   top: 0;
005   width: 100%;
006   left: -100%;
007   -webkit-transition: 0.3s ease-in-out;
008   -o-transition: 0.3s ease-in-out;
009   -moz-transition: 0.3s ease-in-out;
010   transition: 0.3s ease-in-out;
011 }
012  
013 .news-affix__items {
014   margin: 0;
015   padding: 0;
016   background-color: #333;
017   display: -webkit-box;
018   display: -webkit-flex;
019   display: -moz-box;
020   display: -ms-flexbox;
021   display: flex;
022   -webkit-box-orient: horizontal;
023   -webkit-box-direction: normal;
024   -webkit-flex-direction: row;
025   -moz-box-orient: horizontal;
026   -moz-box-direction: normal;
027   -ms-flex-direction: row;
028   flex-direction: row;
029   -webkit-flex-wrap: wrap;
030   -ms-flex-wrap: wrap;
031   flex-wrap: wrap;
032 }
033  
034 .news-affix__action {
035   display: block;
036   color: #fff;
037   padding: 15px 10px;
038 }
039  
040 .news-affix__action:hover, .news-affix__action:focus, .news-affix__action:active {
041   text-decoration: none;
042   color: #e6e6e6;
043   background-color: #1a1a1a;
044 }
045  
046 .news-affix__item {
047   position: relative;
048   overflow: hidden;
049   -webkit-box-ordinal-group: 3;
050   -webkit-order: 2;
051   -moz-box-ordinal-group: 3;
052   -ms-flex-order: 2;
053   order: 2;
054 }
055  
056 .news-affix__item.active {
057   display: block;
058   -webkit-box-ordinal-group: 2;
059   -webkit-order: 1;