https://github.com/dynamicdriverepo/ddscrollspy
https://github.com/dynamicdriverepo/ddscrollspy
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dynamicdriverepo/ddscrollspy
- Owner: dynamicdriverepo
- Created: 2013-01-28T07:07:40.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-08-06T19:25:40.000Z (almost 11 years ago)
- Last Synced: 2025-03-30T05:32:02.144Z (3 months ago)
- Language: JavaScript
- Size: 136 KB
- Stars: 12
- Watchers: 0
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DD ScrollSpy Menu #
*Description:* For long pages with lots of content, keeping the user oriented and knowing where within the page he/she is at all times can be challenging. DD ScrollSpy Menu solves this problem, by letting you create a menu whose menu items are automatically highlighted based on the portion of the page the user is currently viewing. As the user scrolls the page, the menu item that points to that section is highlighted (via the injection of a desired CSS class to style it). The script also works on scrollable DIVs within the page to spy on their scroll positions instead. Starting in v1.2, you can now also enable a progress bar to be shown inside each spymenu's menu item to show a progress of how much the user has scrolled within the currently viewed section. DD ScrollSpy "spies" on the visitor's position on the page, but for their benefit (and in turn yours)!
## Directions ##
*Step 1:* This script uses the following external files:
+ jQuery 1.7 or above (served via Google CDN)
+ ddscrollspy.js
+ ddscrollspydemo.css*Step 2:* Add the below code to the HEAD section of your page:
/*
* DD ScrollSpy Menu Script (c) Dynamic Drive (www.dynamicdrive.com)
* Last updated: Aug 1st, 14'
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
*/
jQuery(function($){ // on document load
$('#horizontalmenu').ddscrollSpy({ // initialize first demo
scrolltopoffset: -50
})
$('#verticalspymenu').ddscrollSpy({ // initialize 2nd demo
spytarget: document.getElementById('contentcontainer'),
enableprogress: 'progress',
scrollduration: 300 // <-- no comma after last option!
})
})
function dynamicadditem(){ // function that dynamically adds a new menu item to first demo, spying on #para6
$('#verticalspymenu').append('<li><a href="#para5">Paragraph 5</a></li>')
$('#verticalspymenu').trigger('updatespy')
}
*Step 3:* Then, add the below sample markup to your page:
Paragraph 1
Paragraph 2
Paragraph 3
Paragraph 4
Paragraph 5
This is section 1
This is section 2
This is section 3
This is section 4
This is section 5
## DD ScrollSpy Menu set up ##
See script project page for additional details on setup and documentation: