diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Geshem.js | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/src/Geshem.js b/src/Geshem.js index dd64554..1af397e 100644 --- a/src/Geshem.js +++ b/src/Geshem.js @@ -32,7 +32,25 @@ function Geshem(props) { const imgs = await res.json(); setImages(imgs["280"]); }; - fetchImages(); + + const buildPlayback = async () => { + const date = playback; + const hours = [...Array(24).keys()].map( + h => `${String(h).padStart(2, "0")}` + ); + const minutes = [...Array(6).keys()].map( + m => `${String(m * 10).padStart(2, "0")}` + ); + const paths = hours.reduce( + (acc, h) => + acc.concat(minutes.map(m => `imgs/${date}/${h}${m}/280.png`)), + [] + ); + setImages(paths); + }; + + if (playback) buildPlayback(); + else fetchImages(); }, []); return ( @@ -63,38 +81,6 @@ class OldGeshem extends Component { }); } } - - loadPlaybackData() { - const date = this.state.playback; - const hours = [...Array(24).keys()].map( - h => `${String(h).padStart(2, "0")}` - ); - const minutes = [...Array(6).keys()].map( - m => `${String(m * 10).padStart(2, "0")}` - ); - const paths = hours.reduce( - (acc, h) => acc.concat(minutes.map(m => `imgs/${date}/${h}${m}/280.png`)), - [] - ); - this.setState({ - imgs: { "280": paths } - }); - if (this.state.mapLoaded) { - this.loadSources(); - } - } - - render() { - return ( - <div id="geshem"> - <div - id="map" - ref={el => (this.mapContainer = el)} - className="absolute top right left bottom" - /> - </div> - ); - } } export default App; |
