revert carousel

This commit is contained in:
Martin Quarda 2024-05-08 13:43:28 +02:00
parent 90d5108544
commit 4911f8fdc9

View File

@ -43,14 +43,6 @@ class Main extends Component {
onHashChange(event){ onHashChange(event){
this.setState({page: window.location.hash}) 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})
this.carousel && this. carousel.setState({currentIndex: 1})
}
onSubmit(event){ onSubmit(event){
event.preventDefault(); event.preventDefault();
let form = document.getElementById("form"); let form = document.getElementById("form");
@ -84,25 +76,16 @@ class Main extends Component {
width: photo.original_width, width: photo.original_width,
height: photo.original_height, height: photo.original_height,
}) })
} photos_carousel.push({
if (this.state.photos.length > 3){ source: photo.original
for(let i=this.state.currentImage-1; i<=this.state.currentImage+1; i++){ })
let j = i; };
if(j < 0){
j += this.state.photos.length;
}
photos_carousel.push({'source': this.state.photos[j % this.state.photos.length].original})
}
}
this.carousel = this.state.photoIsOpen && <Carousel views={photos_carousel} currentIndex={1} trackProps={{onViewChange: (v) => this.onViewChange(v)}}/>
return ( return (
<div> <div>
<ModalGateway> <ModalGateway>
{this.state.photoIsOpen && {this.state.photoIsOpen &&
<Modal onClose={this.togglePhoto}> <Modal onClose={this.togglePhoto}>
{this.carousel} <Carousel views={photos_carousel} currentIndex={this.state.currentImage} />
</Modal> </Modal>
} }
</ModalGateway> </ModalGateway>