AnchorTrigger is a lightweight JavaScript library to run or trigger a callback whenever a user passes through an anchor. A simple use case is to change the active navigation when hovering in a new section in the view.
It’s designed to be efficient, for example, callbacks are reduced to 50ms rather than persisted (you can change that). The library has no dependencies and is only 1k when compressed in gz format. The source should be very straightforward and easy to update. It is written in plain old ES5.
Trigger Functions When You Scroll To An Element | VueWaypoint
How to make use of it:
To get started, simply include the anchor-Trigger.js at the bottom of the webpage.
<script src="anchor-trigger.js"></script>
Basic use:
var obj = AnchorTriggre( listOfAnchorNames, callback, [options] )
The available choices.
// tags to query as anchors. query: 'a', // Only call callback when anchor has changed. onlyOnChange: true / // fraction of page (top to bottom or left to right) to trigger new area. fraction: .5, // Delay to throttle calls during scroll delay: 50, // The element we are watching for scroll. bind: window, // Direction of scroll // 'top' or 'left' flow: 'top', // called even when trigger remains the same. alwaysCallback: undefined
Effecient Scrollspy Library, AnchorTrigger Plugin/Github
See Demo And Download
Official Website(babakness): Click Here
This superior jQuery/javascript plugin is developed by babakness. For extra Advanced Usages, please go to the official website.