jquery - show hide using animate.css bounce -
this works
$(window).on('scroll', function() { scrollposition = $(this).scrolltop(); if (scrollposition > 50) { $('.top-nav').show(); } else { $('.top-nav').hide(); }}); this works once (what happens after bounce out? since cannot element bounce again)
$(window).on('scroll', function() { scrollposition = $(this).scrolltop(); if (scrollposition > 50) { $('.top-nav').css('visibility', 'visible').addclass('animated bounceinleft'); } else { $('.top-nav').addclass('animated bounceoutleft'); } });
your code executing follows:
scrollposition@ top- when
scrollpositiongoes on 50 adding classesanimated,bounceinleft.top-navelement - if
scrollpositionremains on 50 nothing happens - when
scrollpositiongoes below 50, first time, not removingbounceinleftclass instead addingbounceoutleft. in occurrence, when addingbounceoutleftwork, however: - when scrollposition goes below or on 50, both classes
bounceinleft,bounceoutleftassigned.top-navelement => nothing happens.
the above 1 possible scenario, bottom line still same, adding animation classes , not toggling them.
same applies visibility. well, almost...
Comments
Post a Comment