<commit_before>/**
 * @module
 * @prototype {Function} __render
 */

import { SmoothScrollbar } from '../smooth_scrollbar';

export { SmoothScrollbar };

function nextTick(options, current, movement) {
    const { fricton } = options;

    let q = 1 - fricton / 100;
    let next = current + movement * (1 - q);
    let remain = movement * q;

    if (Math.abs(remain) < 1) {
        remain = 0;
        next = current > next ? Math.ceil(next) : Math.floor(next); // stop at integer position
    }

    return {
        position: next,
        movement: remain
    };
};

function __render() {
    const {
        options,
        offset,
        movement,
        __timerID
    } = this;

    if (movement.x || movement.y) {
        let nextX = nextTick(options, offset.x, movement.x);
        let nextY = nextTick(options, offset.y, movement.y);

        movement.x = nextX.movement;
        movement.y = nextY.movement;
<commit_msg>update(render): reduce speed at edge<commit_after>/**
 * @module
 * @prototype {Function} __render
 */

import { SmoothScrollbar } from '../smooth_scrollbar';

export { SmoothScrollbar };

function nextTick(options, current, movement) {
    const { fricton } = options;

    let q = 1 - fricton / 100;
    let next = current + movement * (1 - q);
    let remain = movement * q;

    if (Math.abs(remain) < 1) {
        remain = 0;
        next = current > next ? Math.ceil(next) : Math.floor(next); // stop at integer position
    }

    return {
        position: next,
        movement: remain
    };
};

function __render() {
    const {
        options,
        offset,
        limit,
        movement,
        __timerID
    } = this;

    if ((limit.y - offset.y <= 50 && movement.y > 50) ||
        (offset.y <= 50 && movement.y < -50)) {
        movement.y /= 2;
    }

    if ((limit.x - offset.x <= 50 && movement.x > 50) ||
        (offset.x <= 50 && movement.x < -50)) {
        movement.x /= 2;
    }

    if (movement.x || movement.y) {
        let nextX = nextTick(options, offset.x, movement.x);
        let nextY = nextTick(options, offset.y, movement.y);

        movement.x = nextX.movement;
        movement.y = nextY.movement;

{'fraction_non_alphanumeric': 0.14023831347387716, 'fraction_numerical': 0.01466544454628781, 'mean_word_length': 2.048882681564246, 'pattern_counts': {'":': 0, '<': 11, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6309197', 'n_tokens_mistral': 734, 'n_tokens_neox': 703, 'n_words': 183}