<commit_before>import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import debounce from 'lodash-es/debounce';
import {Scroller} from './Scroller';

export default class Scrollable extends Component {
    constructor(...args) {
        super(...args);

        this.state = {
            viewPortHeight: this._viewPortHeight({isBodyScroll: true}),
            scrollTop: this._scrollTop({isBodyScroll: true})
        };
        this.onScroll = () => this._onScroll(this.props);
        this.onResize = () => this._onResize();
        this.debouncedUpdateSize = debounce(() => this._updateSize(this.props), 100);
    }

    _onScroll(props) {
        this.setState({scrollTop: this._scrollTop(props)});
    }

    _onResize() {
        this.debouncedUpdateSize();
    }

    _updateSize(props) {
        this.setState({viewPortHeight:  this._viewPortHeight(props)});
    }

    _scrollTop({isBodyScroll}) {
        return isBodyScroll ?
            window.pageYOffset: ReactDOM.findDOMNode(this.refs.container).scrollTop;
    }

    _viewPortHeight({isBodyScroll}) {
        return isBodyScroll ? window.innerHeight : ReactDOM.findDOMNode(this.refs.container).offsetHeight;<commit_msg>feat(scroll): Added throttling for onScroll event<commit_after>import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import debounce from 'lodash-es/debounce';
import throttle from 'lodash-es/throttle';
import {Scroller} from './Scroller';

export default class Scrollable extends Component {
    constructor(...args) {
        super(...args);

        this.state = {
            viewPortHeight: this._viewPortHeight({isBodyScroll: true}),
            scrollTop: this._scrollTop({isBodyScroll: true})
        };
        this.onScroll = throttle(() => this._onScroll(this.props), 50);
        this.onResize = () => this._onResize();
        this.debouncedUpdateSize = debounce(() => this._updateSize(this.props), 100);
    }

    _onScroll(props) {
        this.setState({scrollTop: this._scrollTop(props)});
    }

    _onResize() {
        this.debouncedUpdateSize();
    }

    _updateSize(props) {
        this.setState({viewPortHeight:  this._viewPortHeight(props)});
    }

    _scrollTop({isBodyScroll}) {
        return isBodyScroll ?
            window.pageYOffset: ReactDOM.findDOMNode(this.refs.container).scrollTop;
    }

    _viewPortHeight({isBodyScroll}) {
        return isBodyScroll ? window.innerHeight : ReactDOM.findDOMNode(this.refs.container).offsetHeight;
{'fraction_non_alphanumeric': 0.13282808137215796, 'fraction_numerical': 0.0031910650179497405, 'mean_word_length': 3.1182266009852215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '610011', 'n_tokens_mistral': 761, 'n_tokens_neox': 728, 'n_words': 126}