Commit 86b054ee authored by alain's avatar alain 🐙
Browse files

fix touch devices click bug

parent bd6b999e
......@@ -17,6 +17,7 @@ class Modal extends React.Component {
}
componentDidMount(){
this.mountTime = + new Date()
document.addEventListener("keydown", this.handleKeydown, false)
}
......@@ -28,7 +29,10 @@ class Modal extends React.Component {
const closeModal = this.props.closeModal
return (
<div className="modal" onClick={event => closeModal(event)}>
<div className="modal" onClick={event => {
// Prevent closing on double click / touch devices (it's registering a click event for some reason..)
if(+ new Date() - this.mountTime > 300) closeModal(event)
}}>
<div className="content" onClick={event => { event.stopPropagation() }}>
<button className="button-close" onClick={event => closeModal(event)}>×</button>
{this.props.children}
......
......@@ -21,7 +21,6 @@ const moment = extendMoment(Moment)
const start = getMonthsAgoHourISO(3)
const end = getNowISO()
//const scale = scaleLog()
class StationInfo extends React.Component {
constructor(props) {
......@@ -68,12 +67,14 @@ class StationInfo extends React.Component {
})
}
this.setState({ data, stationMeta, unit })
if(this.mounted) {
this.setState({ data, stationMeta, unit })
const startIndex = (data.length - 7*24 > 0 ? data.length - 7*24 : 0)
const dataStart = moment(data[startIndex].timestamp)
const dataEnd = moment(data[data.length-1].timestamp)
this.setTickSettings(dataStart, dataEnd)
const startIndex = (data.length - 7*24 > 0 ? data.length - 7*24 : 0)
const dataStart = moment(data[startIndex].timestamp)
const dataEnd = moment(data[data.length-1].timestamp)
this.setTickSettings(dataStart, dataEnd)
}
})
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment