Posted in Usefull jQuery Code

Simple jQuery Code For On Scrolling Animation And Scroll Top Fix Menu

        /*----------------------------
            SCROLL TO TOP
        ------------------------------*/
        $(window).scroll(function () {
            var totalHeight = $(window).scrollTop();

            if (totalHeight > 100) {
                $('.mainmenu-area').addClass('fixed');
            } else {
                $('.mainmenu-area').removeClass('fixed');
            }

            if (totalHeight > 300) {
                $(".scrolltotop").fadeIn();
            } else {
                $(".scrolltotop").fadeOut();
            }

            // scroll and fade header text
            $('.welcome-slider-area').css({
                'margin-top': -(totalHeight / 4) + "px",
                'opacity': 1 - (totalHeight / 500)
            });
        });
Advertisements