Navigate your web page with a smooth scrolling animation.
Live demonstration on our website and on GitHub pages.
- jQuery 3.3.1< (not slim)
- Download
dist/scroller.min.js
from this GitHub Repository. - Place
scroller.min.js
in a public JavaScript directory.
Load the library and initialize the window.Deasilsoft.Scroller(links, userOptions)
function.
The array of links
. A link
is usually an octothorpe followed by a single word to describe the contents of that page.
The order of every link
will matter, as the going to the previous or next page will strictly follow your links
order. The first and last link
will loop.
{
Navigation: {
Class: {
Active: "active"
},
Selector: {
ActiveParentLink: true,
Active: "body > header .nav-item.active",
Link: "body > header .nav-link[href^='{{link}}']"
}
},
ResizeTimeout: 250,
ScrollTimeout: 100,
TouchThreshold: 0.66,
LoadLink: 0
}
The HTML class attribute that indicates which link
is currently active.
(default: "active")
true
: Apply Navigation.Class.Active
to parent of link
anchor.
(default)
false
: Apply Navigation.Class.Active
to link
anchor.
The selector to the currently active link
.
(default: "body > header .nav-item.active")
The selector to a particular link
. This will replace {{ link }}
with the link
.
(default: "body > header .nav-link[href^='{{link}}']")
The time in milliseconds between last resize
event and our trigger to adjust to the current link
.
(default: 250)
The time in millisecond between scroll
and our trigger to go to the previous or next link
.
(default: 100)
The % of the screen mobile users need to swipe in order to go to previous or next link
. A high % is adviced.
(default: 0.66)
The default link
to start the document on. 0 is the first link
in your array of links
.
(default: 0)
<!-- jQuery is required -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" crossorigin="anonymous"></script>
<!-- Load the libarary -->
<script type="text/javascript" src="scroller.min.js"></script>
<!-- Initialize the instance -->
<script type="text/javascript">
window.Deasilsoft.Scroller(["#home", "#products", "#about", "#contact"]);
</script>