A jQuery plugin that modifies a navigation menu to highlight / change when the menu's target smooth scrolls into view
offsetTop
option - adds a top offset value (pixels) or jQuery element (height is measured), of any top menu or gap.scrollOnInit
option - prevents initial scroll to top menu item when set to false
(default value).contentClass
option) will target the top of the content block.animationTime
option to now accept a function
The animationTime
option still accepts a time in milliseconds.
To set an animationTime
based on the scroll distance, use any desired calculation method and return a time in milliseconds.
For example, in this snippet, the distance is halfed and returned as an animation time in milliseconds:
animationTime: function( distance ) {
// distance in pixels; return time in milliseconds
// 1000 pixels => 500ms; 10000 pixels => 5000ms
return distance / 2;
}