javascript - Jquery waypoints with smooth scroll -
i having little trouble jquery waypoints here. im using auto scroll navigation on 1 page site:
it works fine when use scroll wheel. need change color of nav items whenever element reaches top of screen. problem when press sign --> --> sign up, doesnt change color third time.
script.js:
$('a[href^="#"]').bind('click.smoothscroll',function (e) { e.preventdefault(); var target = this.hash, $target = $(target); $('html, body').stop().animate({ 'scrolltop': $target.offset().top-40 }, 900, 'swing', function () { window.location.hash = target; }); }); var currentmenuobject = ''; $('#wrapper').waypoint(function() { $(currentmenuobject).css('color', '#f2e0bd'); currentmenuobject = '#top'; $(currentmenuobject).css('color', 'black'); }, { offset: '55'}); $('#introarticle').waypoint(function() { $(currentmenuobject).css('color', '#f2e0bd'); currentmenuobject = '#top'; $(currentmenuobject).css('color', 'black'); }, { offset: '55'}); $('#signsection').waypoint(function() { $(currentmenuobject).css('color', '#f2e0bd'); currentmenuobject = '#signup'; $(currentmenuobject).css('color', 'black'); }, { offset: '55'}); $('#storyarticle').waypoint(function() { $(currentmenuobject).css('color', '#f2e0bd'); currentmenuobject = '#about'; $(currentmenuobject).css('color', 'black'); }, { offset: '55'});
you calling bit before adding jquery page:
$(document).ready(function(){ //jquery code goes here , executed page has finished loading }); this throws $ not function error , stops executing code.
Comments
Post a Comment