<commit_before>window.onload = function () {
    'use strict';

    var view, images, left, center, right,
        index, count, offset, snap,
        pressed, reference, amplitude, target, velocity, timeConstant,
        xform, frame, timestamp, ticker;

    function initialize() {
        var i, stash, el;

        count = 10;
        images = [];
        index = 5;
        offset = 0;
        timeConstant = 125; // ms
        pressed = false;

        snap = window.innerWidth;

        view = document.getElementById('content');
        left = document.getElementById('left');
        center = document.getElementById('center');
        right = document.getElementById('right');

        left.setAttribute('width', snap + 'px');
        center.setAttribute('width', snap + 'px');
        right.setAttribute('width', snap + 'px');


        // Predownloads some images.
        stash = document.getElementById('stash');
        for (i = 0; i < count; ++i) {
            el = document.createElement('img');
            el.setAttribute('src', 'images/' + i + '.jpg');
            stash.appendChild(el);
            images.push(el);
        }
    }

    function setupEvents() {
        if (typeof window.ontouchstart !== 'undefined') {
            view.addEventListener('touchstart', tap);
            view.addEventListener('touchmove', drag);
            view.addEventListener('touchend', release);
        }
        view.addEventListener('mousedown', tap);
        view.addEventListener('mousemove', drag);
        view.addEventListener('mouseup', release);
    }

    function xpos(e) {
        // touch event
        if (e.targetTouches && (e.targetTouches.length >= 1)) {
            return e.targetTouches[0].clientX;
        }

        // mouse event
        return e.clientX;
    }

    function wrap(x) {
        return (x >= count) ? (x - count) : (x < 0) ? x + count : x;
    }

    function display(i) {
        offset = 0;
        index = i;
        left.setAttribute('src', images[wrap(index - 1)].getAttribute('src'));
        center.setAttribute('src', images[wrap(index)].getAttribute('src'));
        right.setAttribute('src', images[wrap(index + 1)].getAttribute('src'));
        scroll(0);
    }

    function scroll(x) {
        var slow, fast;

        offset = x;
        slow = -Math.round(offset / 2);
        fast = -Math.round(offset);

        left.style[xform] = 'translate3d(' + (fast - snap) + 'px, 0, 0)';
        center.style[xform] = 'translate3d(' + slow + 'px, 0, 0)';
        right.style[xform] = 'translate3d(' + (fast + snap) + 'px, 0, 0)';
    }

    function track() {
        var now, elapsed, delta, v;

        now = Date.now();
        elapsed = now - timestamp;
        timestamp = now;
        delta = offset - frame;
        frame = offset;

        v = 1000 * delta / (1 + elapsed);
        velocity = 0.8 * v + 0.2 * velocity;<commit_msg>Reduce the chance of flickering.<commit_after>window.onload = function () {
    'use strict';

    var view, images, left, center, right,
        index, count, offset, snap,
        pressed, reference, amplitude, target, velocity, timeConstant,
        xform, frame, timestamp, ticker;

    function initialize() {
        var i, stash, el;

        count = 10;
        images = [];
        index = 5;
        offset = 0;
        timeConstant = 125; // ms
        pressed = false;

        snap = window.innerWidth;

        view = document.getElementById('content');
        left = document.getElementById('left');
        center = document.getElementById('center');
        right = document.getElementById('right');

        left.setAttribute('width', snap + 'px');
        center.setAttribute('width', snap + 'px');
        right.setAttribute('width', snap + 'px');


        // Predownloads some images.
        stash = document.getElementById('stash');
        for (i = 0; i < count; ++i) {
            el = document.createElement('img');
            el.setAttribute('src', 'images/' + i + '.jpg');
            stash.appendChild(el);
            images.push(el);
        }
    }

    function setupEvents() {
        if (typeof window.ontouchstart !== 'undefined') {
            view.addEventListener('touchstart', tap);
            view.addEventListener('touchmove', drag);
            view.addEventListener('touchend', release);
        }
        view.addEventListener('mousedown', tap);
        view.addEventListener('mousemove', drag);
        view.addEventListener('mouseup', release);
    }

    function xpos(e) {
        // touch event
        if (e.targetTouches && (e.targetTouches.length >= 1)) {
            return e.targetTouches[0].clientX;
        }

        // mouse event
        return e.clientX;
    }

    function wrap(x) {
        return (x >= count) ? (x - count) : (x < 0) ? x + count : x;
    }

    function display(i) {
        offset = 0;
        index = i;
        center.style[xform] = 'translate3d(0, 0, 0)';
        center.setAttribute('src', images[wrap(index)].getAttribute('src'));
        scroll(0);
        left.setAttribute('src', images[wrap(index - 1)].getAttribute('src'));
        right.setAttribute('src', images[wrap(index + 1)].getAttribute('src'));
    }

    function scroll(x) {
        var slow, fast;

        offset = x;
        slow = -Math.round(offset / 2);
        fast = -Math.round(offset);

        left.style[xform] = 'translate3d(' + (fast - snap) + 'px, 0, 0)';
        center.style[xform] = 'translate3d(' + slow + 'px, 0, 0)';
        right.style[xform] = 'translate3d(' + (fast + snap) + 'px, 0, 0)';
    }

    function track() {
        var now, elapsed, delta, v;

        now = Date.now();
        elapsed = now - timestamp;
        timestamp = now;
        delta = offset - frame;
        frame = offset;

        v = 1000 * delta / (1 + elapsed);
        velocity = 0.8 * v + 0.2 * velocity;
{'fraction_non_alphanumeric': 0.15122034476873186, 'fraction_numerical': 0.01228878648233487, 'mean_word_length': 2.023735810113519, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3565044', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1673, 'n_words': 407}