From 69df1f01d6cd85fa3d3eca5986b81bbe3afebd2c Mon Sep 17 00:00:00 2001 From: Martin Quarda Date: Wed, 8 May 2024 13:15:01 +0200 Subject: [PATCH] test of new gallery --- frontend/src/scripts/index.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/frontend/src/scripts/index.js b/frontend/src/scripts/index.js index 6155ba7..8e6c276 100644 --- a/frontend/src/scripts/index.js +++ b/frontend/src/scripts/index.js @@ -43,6 +43,13 @@ class Main extends Component { onHashChange(event){ this.setState({page: window.location.hash}) } + onViewChange(index){ + let new_index = (this.state.currentImage - 1 + index) % this.state.photos.length + if (new_index < 0){ + new_index += this.state.photos.length + } + this.setState({currentImage: new_index}) + } onSubmit(event){ event.preventDefault(); let form = document.getElementById("form"); @@ -76,16 +83,22 @@ class Main extends Component { width: photo.original_width, height: photo.original_height, }) - photos_carousel.push({ - source: photo.original - }) - }; + } + if (this.state.photos.length > 3){ + for(let i=this.state.currentImage - 1; i<=this.state.currentImage + 1; i++){ + if(i < 0){ + i += this.state.photos.length; + } + photos_carousel.push({'source': this.state.photos[i].original}) + } + } + return (
{this.state.photoIsOpen && - + this.onViewChange(v)}}/> } @@ -103,7 +116,7 @@ class Main extends Component { {this.state.page == "#gallery" &&
- +
} {this.state.page == "" &&