import React, { Component } from 'react' import { connect } from 'react-redux' import './jakrawal.links.css' import { history } from "site/store" const JAKRAWAL_TEXTS = [ "Wildfires occur frequently during the dry season in northern Thailand’s high mountains. The source of fire is not natural but arson.", "In the past it was hypothesized that local people set the fires to clear land for agricultural use, or for hunting.", "There were efforts to solve the problem at the community level, but the fires only became more severe.", "Strangely, the blazes often occurred in the national park—an area difficult for villagers to access.", "During the wildfire suppression efforts of May 2020, a group of scholars and volunteers discovered important evidence that would change the original hypothesis.", "They found several instances of improvised devices made of clothes pegs connected to a small battery by a power cable.", "Combustion was triggered by a small clod of clay positioned in the middle between the pegs, acting as a timer. After melting in the heat the wires attached to the batteries would ignite.", "Villagers who were interviewed said that this was not a technique that they were familiar with.", "Although we cannot know the intention of the burners, it is likely that the park’s natural resources are being used to benefit some group of people. And the poor have always been condemned.", ] const RESET_STATE = { left: null, right: null, lateralLink: null, verticalLink: null, text: null, hovering: false, } const VERTICAL_TIMEOUT = 40000 class JakrawalLinks extends Component { state = { ...RESET_STATE } constructor(props) { super(props) this.goLateral = this.goLateral.bind(this) this.goVertical = this.goVertical.bind(this) this.handleEnter = this.handleEnter.bind(this) this.handleLeave = this.handleLeave.bind(this) } componentDidMount() { if (this.props.interactive) { this.load() } } componentDidUpdate(prevProps) { if ( (this.props.interactive && this.props.interactive !== prevProps.interactive) || this.props.location.pathname !== prevProps.location.pathname ) { this.load(prevProps.match && prevProps.match.params) } } load(lastParams) { const { page_name } = this.props.match.params const page_partz = page_name.split("-") const isJakrawal = page_partz[0] === 'nilthamrong' if (!isJakrawal || page_partz[1] === 'home') { clearTimeout(this.timeout) this.setState({ ...RESET_STATE, }) return } if (page_partz[1] === 'a9') { clearTimeout(this.timeout) this.timeout = setTimeout(this.goVertical, VERTICAL_TIMEOUT) this.setState({ ...RESET_STATE, verticalLink: "home", }) return } const partz = page_partz[1].split("") const isOnA = partz[0] === 'a'; const lateralLink = (isOnA ? 'b' : 'a') + partz[1] const verticalLink = partz[0] + (parseInt(partz[1]) + 1) const text = JAKRAWAL_TEXTS[parseInt(partz[1]) - 1] this.setState({ left: !isOnA, right: isOnA, lateralLink, verticalLink, text, hovering: false, }) if (!lastParams || lastParams.page_name !== ('nilthamrong' + lateralLink)) { clearTimeout(this.timeout) this.timeout = setTimeout(this.goVertical, VERTICAL_TIMEOUT) } } handleEnter() { this.setState({ hovering: true }) } handleLeave() { this.setState({ hovering: false }) } goLateral() { history.push(`/last-museum/nilthamrong-${this.state.lateralLink}/`) } goVertical() { history.push(`/last-museum/nilthamrong-${this.state.verticalLink}/`) } render() { const { left, right, text, hovering } = this.state if (!this.props.interactive || !text) return null return (
{left &&
} {right &&
} {text &&
} {text &&
}
) } } const mapStateToProps = state => ({ interactive: state.site.interactive, }) export default connect(mapStateToProps)(JakrawalLinks)