<commit_before>﻿'use strict';

import React from 'react';

import { checkSmoothScrollSupport } from 'js/utils';

const isSmoothScrollSupported = checkSmoothScrollSupport();
const FADE_TIMEOUT = 400;

function fadeIn(WrappedComponent, shouldAnimateOnUpdate) {
    return class extends React.Component {
        componentDidMount() {
            this.fadeIn();
            this.scrollIntoView();
        }

        componentDidUpdate(prevProps, prevState) {
            if (shouldAnimateOnUpdate && shouldAnimateOnUpdate(prevProps, prevState, this.props, this.state)) {
                this.fadeIn();
                this.scrollIntoView();
            }
        }

        fadeIn() {
            this.node.classList.add('fade-in');
            setTimeout(() => { this.node.classList.remove('fade-in') }, FADE_TIMEOUT);
        }

        scrollIntoView() {
            if (!isSmoothScrollSupported) return;
            this.node.scrollIntoView({ behavior: 'smooth' });
        }

        render() {
            return (
                <div className='animation-container' ref={(node) => { this.node = node; }}>
                    <WrappedComponent {...this.props} />
                </div>
            )
        }
    }<commit_msg>fix bug in fadeInHOC<commit_after>﻿'use strict';

import React from 'react';

import { checkSmoothScrollSupport } from 'js/utils';

const isSmoothScrollSupported = checkSmoothScrollSupport();
const FADE_TIMEOUT = 400;

function fadeIn(WrappedComponent, shouldAnimateOnUpdate) {
    return class extends React.Component {
        componentDidMount() {
            this.fadeIn();
            this.scrollIntoView();
        }

        componentDidUpdate(prevProps, prevState) {
            if (shouldAnimateOnUpdate && shouldAnimateOnUpdate(prevProps, prevState, this.props, this.state)) {
                this.fadeIn();
                this.scrollIntoView();
            }
        }

        componentWillUnmount() {
            clearTimeout(this.timeoutId);
        }

        fadeIn() {
            this.node.classList.add('fade-in');
            clearTimeout(this.timeoutId);
            this.timeoutId = setTimeout(() => { this.node.classList.remove('fade-in') }, FADE_TIMEOUT);
        }

        scrollIntoView() {
            if (!isSmoothScrollSupported) return;
            this.node.scrollIntoView({ behavior: 'smooth' });
        }

        render() {
            return (
                <div className='animation-container' ref={(node) => { this.node = node; }}>
                    <WrappedComponent {...this.props} />
                </div>
            )
        }
    }
{'fraction_non_alphanumeric': 0.12165263963274675, 'fraction_numerical': 0.0022953328232593728, 'mean_word_length': 1.9614949037372593, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6623178', 'n_tokens_mistral': 732, 'n_tokens_neox': 697, 'n_words': 123}