<commit_before>;(function($){

    $.unveiledNavigation = function(element, options) {

        var that        = this;
        // MERGE OPTIONS
        var opts        = $.extend({}, $.fn.unveiledNavigation.defaults, options);

        // VIEW COMPONENTS
        var $this       = $(element);

        // PROPERTIES
        var scrollTop               = $(window).scrollTop();
        var scrollDirection         = 1;
        var top                     = 0;
        var unveilTimeout           = undefined;


        /********************************/
        /* PRIVATE FUNCTIONS            */
        /********************************/

        var init = function(){
            initListeners();
        };

        var initListeners = function(){
            $(window).on('scroll', onWindowScroll);
            onWindowScroll();
        };


        /**
         * unveil
         * Unveils the navigation
         **/
        this.unveil = function(){
            $this.animate(
                {
                    top: 0
                },{
                    step: function( now ){
                        top = now;
                    },
                    easing: opts.easing,
                    duration: opts.duration
                }
            );
        };

        /**
         * cover
         * covers the navigation
         **/
        this.cover = function(){
            $this.animate(
                {
                    top: -$this.outerHeight()
                },{
                    step: function( now ){
                        top = now;
                    },
                    easing: opts.easing,
                    duration: opts.duration
                }
            );
        }

        /********************************/
        /* EVENT HANDLING               */
        /********************************/

        var onWindowScroll = function( event ){

            // Stop unveil animation if any
            $this.stop();

            // Calculate new scrollTop and scrollDelta
            var newScrollTop       = Math.max(0, $(window).scrollTop());
            var scrollDelta        = scrollTop - newScrollTop;

            // Calculate new top position
            var newTop          = top + scrollDelta * opts.acceleration;
            newTop              = Math.max(newTop, -$this.outerHeight() - opts.offset);
            newTop              = Math.min(newTop, 0);

            // Unveil completely if just partly unveiled
            clearTimeout(unveilTimeout);
            if(scrollDirection == 1 && Math.abs(newTop) < $this.outerHeight()){
                unveilTimeout = setTimeout(that.unveil, opts.timeout)
            }

            // Show when scrolled to the very bottom
            if(newScrollTop == $(document).height() - $(window).height() && opts.unveilAtBottom){
                that.unveil();
            }

            // Assign class if scrolled to the very top
            if(newScrollTop == 0){
                $this.addClass(opts.topClass);
            }else if(newScrollTop > $this.outerHeight()){
                $this.removeClass(opts.topClass);
            }

            // Asign new position
            $this.css({ top: newTop });


            // Update memory
            top                = newTop;
            scrollTop          = newScrollTop;
            scrollDirection    = scrollDelta ? scrollDelta/Math.abs(scrollDelta) : scrollDirection;
        };

        /********************************/
        /* INIT                         */
        /********************************/

        init();

    };

    /**
    * PLUGIN INIT
    *
    */
    $.fn.unveiledNavigation = function(options){
        return this.each(function() {
            if (undefined === $(this).data('unveiledNavigation')) {
                var plugin = new $.unveiledNavigation(this, options);
                $(this).data('unveiledNavigation', plugin);
            }
        });
    };

    /**
    * PLUGIN DEFAULTS
    *
    */
    $.fn.unveiledNavigation.defaults = {
        offset:         0,          // Offset in px for unveiling
        acceleration:   1,          // Acceleration of unveiling/hiding
        topClass:       'at-top',   // Class that will be added when at the top
        timeout:        300,        // Timeout before the navigation gets unveiled on scroll stop
        easing:         'swing',    // Esing function that is used for automatical unveiling/hiding
        duration:       500,         // Duration of the automatic unveiling/hiding
        unveilAtBottom: true        // Should the navigation be unveiled automatically when reacing the bottom of the page?
    };

})(jQuery);<commit_msg>Added options for dynamic element classes depending on scroll direction<commit_after>;(function($){

    $.unveiledNavigation = function(element, options) {

        var that        = this;
        // MERGE OPTIONS
        var opts        = $.extend({}, $.fn.unveiledNavigation.defaults, options);

        // VIEW COMPONENTS
        var $this       = $(element);

        // PROPERTIES
        var scrollTop               = $(window).scrollTop();
        var scrollDirection         = 1;
        var top                     = 0;
        var unveilTimeout           = undefined;


        /********************************/
        /* PRIVATE FUNCTIONS            */
        /********************************/

        var init = function(){
            initListeners();
        };

        var initListeners = function(){
            $(window).on('scroll', onWindowScroll);
            onWindowScroll();
        };


        /**
         * unveil
         * Unveils the navigation
         **/
        this.unveil = function(){
            $this.animate(
                {
                    top: 0
                },{
                    step: function( now ){
                        top = now;
                    },
                    easing: opts.easing,
                    duration: opts.duration
                }
            );
        };

        /**
         * cover
         * covers the navigation
         **/
        this.cover = function(){
            $this.animate(
                {
                    top: -$this.outerHeight()
                },{
                    step: function( now ){
                        top = now;
                    },
                    easing: opts.easing,
                    duration: opts.duration
                }
            );
        }

        /********************************/
        /* EVENT HANDLING               */
        /********************************/

        var onWindowScroll = function( event ){

            // Stop unveil animation if any
            $this.stop();

            // Calculate new scrollTop and scrollDelta
            var newScrollTop       = Math.max(0, $(window).scrollTop());
            var scrollDelta        = scrollTop - newScrollTop;

            // Calculate new top position
            var newTop          = top + scrollDelta * opts.acceleration;
            newTop              = Math.max(newTop, -$this.outerHeight() - opts.offset);
            newTop              = Math.min(newTop, 0);

            // Unveil completely if just partly unveiled
            clearTimeout(unveilTimeout);
            if(scrollDirection == 1 && Math.abs(newTop) < $this.outerHeight()){
                unveilTimeout = setTimeout(that.unveil, opts.timeout)
            }

            $this.removeClass(opts.upClass).removeClass(opts.downClass);
            var directionClass = scrollDirection > 0 ? opts.upClass : opts.downClass;
            $this.addClass(directionClass)

            // Show when scrolled to the very bottom
            if(newScrollTop == $(document).height() - $(window).height() && opts.unveilAtBottom){
                that.unveil();
            }

            // Assign class if scrolled to the very top
            if(newScrollTop == 0){
                $this.addClass(opts.topClass);
            }else if(newScrollTop > $this.outerHeight()){
                $this.removeClass(opts.topClass);
            }

            // Asign new position
            $this.css({ top: newTop });


            // Update memory
            top                = newTop;
            scrollTop          = newScrollTop;
            scrollDirection    = scrollDelta ? scrollDelta/Math.abs(scrollDelta) : scrollDirection;
        };

        /********************************/
        /* INIT                         */
        /********************************/

        init();

    };

    /**
    * PLUGIN INIT
    *
    */
    $.fn.unveiledNavigation = function(options){
        return this.each(function() {
            if (undefined === $(this).data('unveiledNavigation')) {
                var plugin = new $.unveiledNavigation(this, options);
                $(this).data('unveiledNavigation', plugin);
            }
        });
    };

    /**
    * PLUGIN DEFAULTS
    *
    */
    $.fn.unveiledNavigation.defaults = {
        offset:         0,          // Offset in px for unveiling
        acceleration:   1,          // Acceleration of unveiling/hiding
        topClass:       'at-top',   // Class that will be added when at the top
        upClass:       '',   // Class that will be added when last scroll movement was upwards
        downClass:       '',   // Class that will be added when last scroll movement was downwards
        timeout:        300,        // Timeout before the navigation gets unveiled on scroll stop
        easing:         'swing',    // Esing function that is used for automatical unveiling/hiding
        duration:       500,         // Duration of the automatic unveiling/hiding
        unveilAtBottom: true        // Should the navigation be unveiled automatically when reacing the bottom of the page?
    };

})(jQuery);
{'fraction_non_alphanumeric': 0.13805327661298492, 'fraction_numerical': 0.003139876430669503, 'mean_word_length': 1.2719742291762541, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7641641', 'n_tokens_mistral': 2474, 'n_tokens_neox': 2284, 'n_words': 572}