jquery - Fixed floating element-adding animation to addclass -
i want add fadein effect menu when changes classes fixed position @ top when scroll down page.
the js:
$(function () { var msie6 = $.browser == 'msie' && $.browser.version < 7; if (!msie6) { var top = $('#navmenu').offset().top - parsefloat($('#navmenu').css('margin-top').replace(/auto/, 0)); $(window).scroll(function (event) { var y = $(this).scrolltop(); if (y >= top) { $('#navmenu').addclass('fiksed'); } else { $('#navmenu').removeclass('fiksed'); } }); } });
is effect looking for?
the code:
<script> $(function () { var msie6 = $.browser == 'msie' && $.browser.version < 7; if (!msie6) { var top = $('#navmenu').offset().top - parsefloat($('#navmenu').css('margin-top').replace(/auto/, 0)); $(window).scroll(function (event) { // y position of scroll var y = $(this).scrolltop(); // whether that's below form if (y >= top) { // if so, ad fixed class if ( $('#navmenu').is('.fiksed') ) { return; } $('#navmenu').hide().addclass('fiksed').fadein(); } else { // otherwise remove $('#navmenu').removeclass('fiksed'); } }); } }); </script>
Comments
Post a Comment