<commit_before>(function ($) {
    
    var contentTop = [],
    content = [],
    lastScrollTop = 0,
    scrollDir = '',
    itemClass = '',
    itemHover = '',
    menuSize = null,
    stickyHeight = 0,
    stickyMarginB = 0,
    currentMarginT = 0,
    $element = $(),
    currentMarginT = 0,
    topMargin = 0,
    top,
    vartop = 0,
    varscroll = 0,
    contentView = $(),
    testView = $();

    function getTopMargin(options) {
        if (options.topMargin == 'auto') {
            return parseInt($('.stuckMenu').css('margin-top'));
        } else {
            if (isNaN(options.topMargin) && options.topMargin.search("px") > 0) {
                return parseInt(options.topMargin.replace("px", ""));
            } else if (!isNaN(parseInt(options.topMargin))) {
                return parseInt(options.topMargin);
            } else {
                console.log("incorrect argument, ignored.");
                return 0;
            }
        }
    }

    $.fn.stickUp = function (options) {
        $element = $(this);
        // adding a class to users div
        $element.addClass('stuckMenu');
        //getting options
        var objn = 0;
        if (options != null) {
            var parts = options.parts;
            for (var key in  parts) {
                if (parts.hasOwnProperty(key)) {
                    content[objn] = parts[objn];
                    objn++;
                }
            }

            itemClass = options.itemClass;
            itemHover = options.itemHover;

            topMargin = (options.topMargin != null) ? getTopMargin(options) : 0;

            menuSize = $('.' + itemClass).size();
        }

        stickyHeight = parseInt($element.height());
        stickyMarginB = parseInt($element.css('margin-bottom'));
        currentMarginT = parseInt($element.next().closest('div').css('margin-top'));
        top = parseInt($element.offset().top);
    };

    function baseScrollHandlerFn(event) {
        var st = $(event.target).scrollTop();
        scrollDir = (st > lastScrollTop) ? 'down' : 'up';
        lastScrollTop = st;
    }

    function stickUpScrollHandlerFn() {
        var scroll = parseInt($(document).scrollTop());
        if (menuSize != null && content.length > 0) {
            for (var i = 0; i < menuSize; i++) {
                contentTop[i] = $('#' + content[i] + '').offset().top;
                function bottomView(i) {
                    var contentView = $('#' + content[i] + '').height() * .4;
                    if (scroll > (contentTop[i] - contentView)) {
                        setItemHover(i);
                    } else if (scroll < 50) {
                        setItemHover(0);
                    }
                }

                if (scrollDir == 'down' && scroll > contentTop[i] - 50 && scroll < contentTop[i] + 50) {
                    setItemHover(i);
                }

                if (scrollDir == 'up') {
                    bottomView(i, contentTop[i]);
                }
            }
        }

        if (top < scroll + topMargin && !$element.hasClass('isStuck')) {

            $element
                .addClass('isStuck')
                .next()
                .closest('div')
                .css({
                    'margin-top': stickyHeight + stickyMarginB + currentMarginT + 'px'
                }, 10);

            $element.css("position", "fixed");

            $element.css({ 
                top: '0px'
            }, 10, function () {

            });
        }

        if (scroll + topMargin < top && $element.hasClass('isStuck')) {

            $element
                .removeClass('isStuck')
                .next()
                .closest('div')
                .css({
                    'margin-top': currentMarginT + 'px'
                }, 10);

            $element.css("position", "relative");
        }
    }

    function setItemHover(position) {
        $('.' + itemClass).removeClass(itemHover);
        $('.' + itemClass + ':eq(' + position + ')').addClass(itemHover);
    }

    $(window).on('scroll', baseScrollHandlerFn);
    $(document).on('scroll', stickUpScrollHandlerFn);

}(jQuery));<commit_msg>reduce layout thrashing<commit_after>(function ($,window,document) {
    
    var contentTop = [],
    content = [],
    lastScrollTop = 0,
    scrollDir = '',
    itemClass = '',
    itemHover = '',
    menuSize = null,
    active = false,
    stickyHeight = 0,
    currentMarginT = 0,
    $element = $(),
    currentMarginT = 0,
    topMargin = 0,
    top,

    getTopMargin = function(options) {
        if (options.topMargin == 'auto') {
            return parseInt($('.stuckMenu').css('margin-top'));
        } else {
            if (isNaN(options.topMargin) && options.topMargin.search("px") > 0) {
                return parseInt(options.topMargin.replace("px", ""));
            } else if (!isNaN(parseInt(options.topMargin))) {
                return parseInt(options.topMargin);
            } else {
                console.log("incorrect argument, ignored.");
                return 0;
            }
        }
    },

    baseScrollHandlerFn = function(event) {
        var st = $(event.target).scrollTop();
        scrollDir = (st > lastScrollTop) ? 'down' : 'up';
        lastScrollTop = st;
        if(!active){
            stickyHeight = parseInt($element.outerHeight(true));
            top = parseInt($element.offset().top);
            currentMarginT = parseInt($element.next().closest('div').css('margin-top'));
        }
    },
     
    stickUpScrollHandlerFn = function() {
        var scroll = parseInt($(document).scrollTop());
        if (menuSize != null && content.length > 0) {
            for (var i = 0; i < menuSize; i++) {
                contentTop[i] = $('#' + content[i] + '').offset().top;
                function bottomView(i) {
                    var contentView = $('#' + content[i] + '').height() * .4;
                    if (scroll > (contentTop[i] - contentView)) {
                        setItemHover(i);
                    } else if (scroll < 50) {
                        setItemHover(0);
                    }
                }

                if (scrollDir == 'down' && scroll > contentTop[i] - 50 && scroll < contentTop[i] + 50) {
                    setItemHover(i);
                }

                if (scrollDir == 'up') {
                    bottomView(i, contentTop[i]);
                }
            }
        }
        
        //STICK IT
        if (top < scroll + topMargin && !$element.hasClass('isStuck')) {
            active = true;
            window.requestAnimationFrame(function() {
                $element
                    .addClass('isStuck')
                    .next()
                    .closest('div')
                    .css({
                        'margin-top': stickyHeight + currentMarginT + 'px'
                    });

                $element.css("position", "fixed");

                $element.css({ 
                    top: '0px'
                });
            });
        }
        
        //UNSTICK
        if (scroll + topMargin < top && $element.hasClass('isStuck')) {
            window.requestAnimationFrame(function() {
                $element
                    .removeClass('isStuck')
                    .next()
                    .closest('div')
                    .css({
                        'margin-top': currentMarginT + 'px'
                    });

                $element.css("position", "relative");
            });
            active = false;
        }
    },

    setItemHover = function(position) {
        $('.' + itemClass).removeClass(itemHover);
        $('.' + itemClass + ':eq(' + position + ')').addClass(itemHover);
    };

    $.fn.stickUp = function (options) {
        $element = $(this);
        // adding a class to users div
        $element.addClass('stuckMenu');
        //getting options
        var objn = 0;
        if (options != null) {
            var parts = options.parts;
            for (var key in  parts) {
                if (parts.hasOwnProperty(key)) {
                    content[objn] = parts[objn];
                    objn++;
                }
            }

            itemClass = options.itemClass;
            itemHover = options.itemHover;

            topMargin = (options.topMargin != null) ? getTopMargin(options) : 0;

            menuSize = $('.' + itemClass).size();
        }

        $(window).on('scroll.stickUp', baseScrollHandlerFn);
        $(document).on('scroll.stickUp', stickUpScrollHandlerFn);
    };
}(jQuery,window,document));
{'fraction_non_alphanumeric': 0.1465547394193774, 'fraction_numerical': 0.00571295324705608, 'mean_word_length': 1.4231638418079096, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1250123', 'n_tokens_mistral': 2433, 'n_tokens_neox': 2328, 'n_words': 441}