diff --git a/frontend/src/scripts/index.js b/frontend/src/scripts/index.js index 1841413..35af3d1 100644 --- a/frontend/src/scripts/index.js +++ b/frontend/src/scripts/index.js @@ -20,6 +20,8 @@ class Main extends Component { results: [], page: window.location.hash, photos: [], + photoIsOpen: false, + currentImage: 0, }; fetch(addr_prefix + "/api/results").then(resp => resp.json()).then(json => { this.setState({results: json}) @@ -29,6 +31,15 @@ class Main extends Component { }) window.addEventListener("hashchange", (e) => {this.onHashChange(e)}) } + togglePhoto = () => { + this.setState(state => ({ photoIsOpen: !state.photoIsOpen })) + } + openPhoto = (event, {index}) => { + this.setState({ + currentImage: index, + photoIsOpen: true, + }) + } onHashChange(event){ this.setState({page: window.location.hash}) } @@ -60,6 +71,7 @@ class Main extends Component { let photos = []; for (const photo of this.state.photos){ photos.push({ + source: photo.original, src: photo.original, width: photo.original_width, height: photo.original_height, @@ -68,6 +80,13 @@ class Main extends Component { console.log(photos, this.state.photos) return (