<commit_before>/**
 * Parallax scrolling
 */
(function ($) {
    var $scrollTop = $('[data-parallax-top]');
    var $scrollBottom = $('[data-parallax-bottom]');
    var factor;
    var scrollPosition = 0;

    /**
     * Get the factor attribute for each
     * @return {[type]} [description]
     */
    var _generateFactor = function () {
        var i = 0;
        var j = 0;

        for (; i < $scrollTop.length; i++) {
            factor = $scrollTop[i].getAttribute('data-parallax-factor') || 4;

            $scrollTop[i].factor = factor;
        }

        for (; j < $scrollBottom.length; j++) {
            factor = $scrollBottom[j].getAttribute('data-parallax-factor') || 4;

            $scrollBottom[j].factor = factor;
        }
    };

    /**
     * Throttle scrolling
     * @param  {function} func
     * @param  {integer}  wait
     * @param  {boolean}  immediate
     * @return {function}
     */
    var _throttle = function (func, wait, immediate) {
        var timeout;

        return function () {
            var later = function () {
                timeout = null;

                if (!immediate) {
                    func.apply(this, arguments);
                }
            };

            var callNow = immediate && !timeout;

            clearTimeout(timeout);
            timeout = setTimeout(later, wait);

            if (callNow) {
                func.apply(this, arguments);
            }
        };
    };

    /**
     * Callback for throttle function
     * @return {void}
     */
    var _callback = function () {
        var scroll = window.pageYOffset;
        var i;
        var factor;

        if (scrollPosition === scroll) {
            window.cancelAnimationFrame(_callback);
            $scrollTop.css('transform', 'translateY(0)');

            return false;
        }

        for (i = 0; i < $scrollTop.length; i++) {
            factor = $scrollTop[i].factor;
            $scrollTop.eq(i).css('transform', 'translateY(' + parseInt(scroll / factor, 10) + 'px)');
        }

        for (i = 0; i < $scrollBottom.length; i++) {
            factor = $scrollBottom[i].factor;
            $scrollBottom.eq(i).css('transform', 'translateY(' + parseInt(scroll / (factor * -1), 10) + 'px)');
        }

        window.cancelAnimationFrame(_callback);
    };

    /**
     * Init
     */
     _generateFactor();

    $(window).on('scroll', function () {
        _throttle(window.requestAnimationFrame(_callback), 100, false);
    });
}(jQuery));<commit_msg>Remove throttle function and add necessity check<commit_after>/**
 * Parallax scrolling
 */
(function ($) {
    var $scrollTop = $('[data-parallax-top]');
    var $scrollBottom = $('[data-parallax-bottom]');
    var factor;
    var scrollPosition = 0;

    /**
     * Get the factor attribute for each
     * @return {[type]} [description]
     */
    var _generateFactor = function () {
        var i = 0;
        var j = 0;

        for (; i < $scrollTop.length; i++) {
            factor = $scrollTop[i].getAttribute('data-parallax-factor') || 4;

            $scrollTop[i].factor = factor;
        }

        for (; j < $scrollBottom.length; j++) {
            factor = $scrollBottom[j].getAttribute('data-parallax-factor') || 4;

            $scrollBottom[j].factor = factor;
        }
    };


    /**
     * Callback for rAF
     * @return {void}
     */
    var _callback = function () {
        var scroll = window.pageYOffset;
        var i;
        var factor;

        if (scrollPosition === scroll) {
            $scrollTop.css('transform', 'translateY(0)');
            window.requestAnimationFrame(_callback);

            return false;
        }

        for (i = 0; i < $scrollTop.length; i++) {
            factor = $scrollTop[i].factor;
            $scrollTop.eq(i).css('transform', 'translateY(' + parseInt(scroll / factor, 10) + 'px)');
        }

        for (i = 0; i < $scrollBottom.length; i++) {
            factor = $scrollBottom[i].factor;
            $scrollBottom.eq(i).css('transform', 'translateY(' + parseInt(scroll / (factor * -1), 10) + 'px)');
        }

        window.requestAnimationFrame(_callback);
    };

    /**
     * Init
     */
    if ($scrollTop.length || $scrollBottom.length) {
        _generateFactor();
        window.requestAnimationFrame(_callback);
    }

}(jQuery));
{'fraction_non_alphanumeric': 0.1533487297921478, 'fraction_numerical': 0.006697459584295612, 'mean_word_length': 1.8455978975032852, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '45124', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1251, 'n_words': 273}