Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.1 kB
2
Indexable
Never
    function effctStickyNavBar() {

        // wind.off( "scroll" );

        let headerSmall = $( ".dsn-nav-bar" );

        headerSmall.removeClass( "header-stickytop" );

        let bodyScroll = 0;

        var $ofContent = $( ".wrapper" ).offset();

        var header = $( ".header-single-post .container" ).offset();

        var post_full_content = $( ".post-full-content" ).offset();

        var scrDown = 0;



        if ( header !== undefined ) {

            $ofContent = header;

        } else if ( $ofContent.top <= 70 ) {

            $ofContent = post_full_content;

        }





        var tl = new TimelineMax( { paused : true } );

        var t2 = new TimelineMax( { paused : true } );

        tl.to( ".header-top .header-container, .site-header ", .5, {

            backgroundColor : "#000",

            paddingTop : 15,

            paddingBottom : 15,

        } );

        tl.reverse();



        t2.to( ".header-top .header-container,  .site-header , .dsn-multi-lang", 0.5, { y : '-100%' } );

        t2.reverse();



        effectScroll.getListener( function ( e ) {



            if ( e.type === "scroll" ) {

                bodyScroll = wind.scrollTop();

            } else {

                bodyScroll = e.offset.y;

            }





            let $top = 70;

            if ( $ofContent !== undefined ) {

                $top = $ofContent.top - 100;

            }

            if($top < 70)

                $top = 70;



            if ( bodyScroll > $top ) {

                tl.play();

                body.addClass( "nav-sticky" );

                if ( scrDown < bodyScroll ) {

                    t2.play();



                } else {

                    t2.reverse();

                }

            } else {

                body.removeClass( "nav-sticky" );

                tl.reverse();

            }





            scrDown = bodyScroll;

        } );

    }