The buty of scrolling for anchors & one-page menus
All popular browsers (does not use history api)
$(function(){
scroller();
});
In that case it will automaticaly find all anchor links and process them! (Chaining is still supporting)
$(function(){
$('h3').scroller();
});
If there is no data-target
or href="#"
attributes this element would become the target itself.
You must specify an id
of the target, no #
is needed for data-target
.
You can also specify the shift (in px) of the scrolling position for each element. Just add the data-shift
attribute.
<a href="#myId" data-sift="30">Some link</a>
<a href="#mySecondId" data-sift="-100">Just another link</a>
This value would be caсhed, so you can set it only for the first time (if several links has the same target).
After the initialization id
's would be changed! At the end of the value would be added the special char
$(function(){
var settings = {
shift: 20,
addClass: false
};
scroller(settings);
});
All your settings would be cached so you must specify them during the first call of the function.
The shift of the scrolling position for all links (in px). Can be overwritten by the data-shift
attribute.
scroller({shift: 10});
Default: 0
Sets the duration of the scrolling effect (in ms).
scroller({time: 500});
Default: 300
Would add the active
class to the links during the scroll (and user scroll too)
scroller({addClasst: false});
Default: true
Will change the hash of the page url on the link click.
scroller({setHashOnClickt: false});
Default: true
Will change the hash of the page url while the user would be scrolling the page.
Can be laggy on macs
scroller({setHashOnScroll: true});
Default: false
It will scroll on page load to the target with the id
specified in the url hash (if hash specified)
scroller({scrollOnLoad: false});
Default: true
You can change char which is add to the target id's. Experemental and not recommended
scroller({additionalChar: '_'});
Default: •