From 3a2f4d0f71e218bb45389390ee378fb82411d201 Mon Sep 17 00:00:00 2001 From: Matthew Gargano Date: Wed, 6 Mar 2013 11:05:09 -0500 Subject: [PATCH] Added ability to update nav element class after scroll event To have the plugin change the class AFTER the scroll event set parameter changeClassBefore to false and you're done! Note: It defaults to true. jQuery('#nav').onePageNav({changeClassBefore: false}); --- jquery.nav.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/jquery.nav.js b/jquery.nav.js index 0f840e4..209d21a 100644 --- a/jquery.nav.js +++ b/jquery.nav.js @@ -45,7 +45,8 @@ scrollThreshold: 0.5, begin: false, end: false, - scrollChange: false + scrollChange: false, + changeClassBefore: true }, init: function() { @@ -151,8 +152,10 @@ self.config.begin(); } - //Change the highlighted nav item - self.adjustNav(self, $parent); + if(self.config.changeClassBefore) { + //Change the highlighted nav item + self.adjustNav(self, $parent); + } //Removing the auto-adjust on scroll self.unbindInterval(); @@ -169,6 +172,11 @@ if(self.config.changeHash) { window.location.hash = newLoc; } + + if(!self.config.changeClassBefore) { + //Change the highlighted nav item + self.adjustNav(self, $parent); + } //Add the auto-adjust on scroll back in self.bindInterval(); @@ -220,4 +228,4 @@ }); }; -})( jQuery, window , document ); \ No newline at end of file +})( jQuery, window , document );