<commit_before>import React from 'react';
import TrackDirCategory from './TrackDirCategory';
import stemdir from '../../store/stemdir.json';
import stemsec from '../../store/stemsec.json';

export class TrackList extends React.Component {
    render() {
        const context = this.context;
        const {is_dir_fixed,current_section} = this.props;
        return (
            <div className='row tracklist'>

                <div
                    className='col-xs-6 col-sm-4 tracklist-directory'
                >
                    <ul
                        id="tracklist-directory-top-list"
                        className={is_dir_fixed ? 'is-fixed' : ''}
                        ref={(el)=>{this.tracklist_directory_top_list=el;}}
                    >
                        { stemdir.map((cat1) => {
                            return (
                                <TrackDirCategory
                                    cat={cat1}
                                    par={context.store}
                                    key={cat1.name}
                                    context={context}
                                />
                            );
                        })}
                    </ul>
                </div>

                <div className='col-xs-6 col-sm-8 tracklist-sections'>
                    { stemsec.map( (sec) => (
                        <section
                            id={sec.section}
                            key={sec.section}
                            ref={(el)=>{
                                if (el) {
                                    this.section_offsets[sec.section] = el.offsetTop;
                                }
                            }}
                            className={sec.section === current_section ? 'is-current' : ''}
                        >
                            { sec.items.map( (item) => (
                                <a href={item} key={item}>{item}</a>
                            ))}
                        </section>
                    )) }
                </div>

            </div>
        );
    }

    componentWillMount() {
        this.section_offsets = {};
    }

    componentDidMount() {
        let me = this;
        const {set_offset,scrolled_to} = me.props;
        if (!window.TRACKLIST_SCROLL_HANDLER) {
            const list = me.tracklist_directory_top_list;
            if (list) {
                let offset = -window.scrollY - 55;
                for (let offsetEl = list; offsetEl; offsetEl = offsetEl.offsetParent) {
                    offset += offsetEl.offsetTop;
                }
                me.initial_offset = offset;
                window.TRACKLIST_SCROLL_HANDLER = window.onscroll = function (evt) {
                    me.scrolled_to(evt.pageY);
                };
            }
        }
    }

    scrolled_to(offset) {
        let me = this;
        let {make_dir_fixed,make_dir_static,set_current_section} = me.props;
        let new_state;<commit_msg>window.scroll is not relevant for initial offset<commit_after>import React from 'react';
import TrackDirCategory from './TrackDirCategory';
import stemdir from '../../store/stemdir.json';
import stemsec from '../../store/stemsec.json';

export class TrackList extends React.Component {
    render() {
        const context = this.context;
        const {is_dir_fixed,current_section} = this.props;
        return (
            <div className='row tracklist'>

                <div
                    className='col-xs-6 col-sm-4 tracklist-directory'
                >
                    <ul
                        id="tracklist-directory-top-list"
                        className={is_dir_fixed ? 'is-fixed' : ''}
                        ref={(el)=>{this.tracklist_directory_top_list=el;}}
                    >
                        { stemdir.map((cat1) => {
                            return (
                                <TrackDirCategory
                                    cat={cat1}
                                    par={context.store}
                                    key={cat1.name}
                                    context={context}
                                />
                            );
                        })}
                    </ul>
                </div>

                <div className='col-xs-6 col-sm-8 tracklist-sections'>
                    { stemsec.map( (sec) => (
                        <section
                            id={sec.section}
                            key={sec.section}
                            ref={(el)=>{
                                if (el) {
                                    this.section_offsets[sec.section] = el.offsetTop;
                                }
                            }}
                            className={sec.section === current_section ? 'is-current' : ''}
                        >
                            { sec.items.map( (item) => (
                                <a href={item} key={item}>{item}</a>
                            ))}
                        </section>
                    )) }
                </div>

            </div>
        );
    }

    componentWillMount() {
        this.section_offsets = {};
    }

    componentDidMount() {
        let me = this;
        const {set_offset,scrolled_to} = me.props;
        if (!window.TRACKLIST_SCROLL_HANDLER) {
            const list = me.tracklist_directory_top_list;
            if (list) {
                let offset = -55;
                for (let offsetEl = list; offsetEl; offsetEl = offsetEl.offsetParent) {
                    offset += offsetEl.offsetTop;
                }
                me.initial_offset = offset;
                window.TRACKLIST_SCROLL_HANDLER = window.onscroll = function (evt) {
                    me.scrolled_to(evt.pageY);
                };
            }
        }
    }

    scrolled_to(offset) {
        let me = this;
        let {make_dir_fixed,make_dir_static,set_current_section} = me.props;
        let new_state;
{'fraction_non_alphanumeric': 0.10339709762532981, 'fraction_numerical': 0.002968337730870712, 'mean_word_length': 0.9339923469387755, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5434602', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1450, 'n_words': 244}