summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorSam Alexander <sxalexander@gmail.com>2011-10-09 23:19:50 -0700
committerSam Alexander <sxalexander@gmail.com>2011-10-09 23:19:50 -0700
commit482d819f8fece21218a3c7b544c424aec2e5a162 (patch)
treef4105d754c0ae7acbe721de2dcaece2154ff08e2 /README.md
parent7b9148a0368ecde50e86a5261a4cdbba256ac10b (diff)
downloadjquery-scrollspy-482d819f8fece21218a3c7b544c424aec2e5a162.zip
jquery-scrollspy-482d819f8fece21218a3c7b544c424aec2e5a162.tar.gz
jquery-scrollspy-482d819f8fece21218a3c7b544c424aec2e5a162.tar.bz2
better readme and adding sticky nav demo
Diffstat (limited to 'README.md')
-rw-r--r--README.md36
1 files changed, 20 insertions, 16 deletions
diff --git a/README.md b/README.md
index b3b791a..b6f98b2 100644
--- a/README.md
+++ b/README.md
@@ -36,18 +36,17 @@ Or clone from:
2. Initialise scrollspy in your document.onload, e.g.:
<script type='text/javascript'>
- $(function() {
- $('.topbar').scrollspy({
- min: 20,
- max: window.height(),
- onEnter: function(element, position){
- $(element).css('position', 'fixed');
- },
- onLeave: function(element, position){
- $(element).css('position', 'relative')
- }
- });
- });
+ $(document).ready(function() {
+ $('#sticky-navigation').scrollspy({
+ min: $('#nav').offset().top,
+ onEnter: function(element, position) {
+ $("#nav").addClass('fixed');
+ },
+ onLeave: function(element, position) {
+ $("#nav").removeClass('fixed');
+ }
+ });
+ });
</script>
Check out the /examples for more info !
@@ -55,23 +54,28 @@ Check out the /examples for more info !
## Documentation:
Options for ScrollSpy include:
+
min: (defaults to 0) The minimum value of the X or Y coordinate, depending on mode.
max: (defaults to 0) The maximum value of the X or Y coordinate, depending on mode.
mode: (defaults to 'vertical') Defines whether to listen to X or Y scrolling.
container: (defaults to window) The element whose scrolling to listen to.
Events for ScrollSpy include:
+
scrollTick: Fires on each scroll event within the min and max parameters. Receives as parameters:
+
position: an object with the current X and Y position.
inside: a Boolean value for whether or not the user is within the min and max parameters
enters: the number of times the min / max has been entered.
leaves: the number of times the min / max has been left.
+
scrollEnter: Fires every time the user enters the min / max zone.
- position: an object with the current X and Y position.
- enters: the number of times the min / max has been entered.
+ position: an object with the current X and Y position.
+ enters: the number of times the min / max has been entered.
+
scrollLeave: Fires every time the user leaves the min / max zone.
- position: an object with the current X and Y position.
- leaves: the number of times the min / max has been left.
+ position: an object with the current X and Y position.
+ leaves: the number of times the min / max has been left.
## A note on forking: