import React, { Component } from 'react' import actions from 'site/actions' import "./artists.css" import { ARTISTS, ARTIST_ORDER } from "site/projects/museum/constants" import { ArrowLeft, ArrowRight } from "site/projects/museum/icons" export default class Artists extends Component { state = { currentIndex: 0, detail: false, } constructor(props) { super(props) this.ref = React.createRef() this.showArtist = this.showArtist.bind(this) this.previousArtist = this.previousArtist.bind(this) this.nextArtist = this.nextArtist.bind(this) } componentDidMount() { actions.site.interact() } showArtist(currentIndex) { this.setState({ detail: true, currentIndex }) this.scrollToTop() } previousArtist() { this.go(-1) } nextArtist() { this.go(1) } go(step) { const currentIndex = (this.state.currentIndex + step + ARTIST_ORDER.length) % ARTIST_ORDER.length this.setState({ currentIndex }) this.scrollToTop() } scrollToTop() { setTimeout(() => { Array.from(this.ref.current.querySelectorAll(".artist-content")).forEach(el => { el.scrollTo(0, 0) }) }, 0) } render() { const { currentIndex, detail } = this.state return (