paul-tqh-nguyen / arxiv_as_a_newspaper

arxiv.org portrayed as if it were a news paper.
0 stars 0 forks source link

Fix Header Row Synchronization Hack #21

Closed paul-tqh-nguyen closed 5 years ago

paul-tqh-nguyen commented 5 years ago

There's a synchronization issue that necessitates delaying the start of our header row's animations to make sure everything's in sync.

See this code in arxiv_as_a_newspaper/front_end/src/Components/HeaderRow.js:


    updateCurrentlyShownResearchFields() {
        let { firstShownResearchFieldIndex } = this.state;
        let { researchFields } = this.props;
        let maxIndex = researchFields.length;
        let updatedFirstShownResearchFieldIndex = firstShownResearchFieldIndex+numShownHeaderRowLinks;
        if (updatedFirstShownResearchFieldIndex >= maxIndex) {
            updatedFirstShownResearchFieldIndex = 0;
        }
        let lastShownResearchFieldIndex = Math.min(maxIndex, updatedFirstShownResearchFieldIndex+numShownHeaderRowLinks);
        this.setState({
            firstShownResearchFieldIndex: updatedFirstShownResearchFieldIndex,
            currentlyShownResearchFields: researchFields.slice(updatedFirstShownResearchFieldIndex, lastShownResearchFieldIndex)
        });
    }

    initializeHeaderRowResearchFieldLoopingInterval() {
        this.headerRowResearchFieldLoopingInterval = setInterval(() => {this.updateCurrentlyShownResearchFields();}, numMillisecondsBetweenHeaderRowUpdates);
    }

    componentDidMount() {
        this.headerRowResearchFieldLoopingIntervalDelayer = setTimeout(() => {
            this.updateCurrentlyShownResearchFields();
            this.initializeHeaderRowResearchFieldLoopingInterval();
        }, numMillisecondsToWaitPriorToInitializingHeaderRowRotations);
    }

Let's fix the underlying issue.

paul-tqh-nguyen commented 5 years ago

https://github.com/paul-tqh-nguyen/arxiv_as_a_newspaper/commit/ae57eb7a869c1367c83c919ca8bc6a5aaf6e2c06 This patch made the sync issue go away.

Let's reopen this issue if the problem reappears.