test of new gallery
This commit is contained in:
parent
b4b975cd2e
commit
69df1f01d6
@ -43,6 +43,13 @@ 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})
|
||||||
|
}
|
||||||
onSubmit(event){
|
onSubmit(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let form = document.getElementById("form");
|
let form = document.getElementById("form");
|
||||||
@ -76,16 +83,22 @@ class Main extends Component {
|
|||||||
width: photo.original_width,
|
width: photo.original_width,
|
||||||
height: photo.original_height,
|
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 (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ModalGateway>
|
<ModalGateway>
|
||||||
{this.state.photoIsOpen &&
|
{this.state.photoIsOpen &&
|
||||||
<Modal onClose={this.togglePhoto}>
|
<Modal onClose={this.togglePhoto}>
|
||||||
<Carousel views={photos_carousel} currentIndex={this.state.currentImage} />
|
<Carousel views={photos_carousel} currentIndex={1} trackProps={{onViewChange: (v) => this.onViewChange(v)}}/>
|
||||||
</Modal>
|
</Modal>
|
||||||
}
|
}
|
||||||
</ModalGateway>
|
</ModalGateway>
|
||||||
@ -103,7 +116,7 @@ class Main extends Component {
|
|||||||
</nav>
|
</nav>
|
||||||
{this.state.page == "#gallery" &&
|
{this.state.page == "#gallery" &&
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<Gallery photos={photos_gallery} onClick={this.openPhoto}/>
|
<Gallery photos={photos_gallery } onClick={this.openPhoto}/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{this.state.page == "" &&
|
{this.state.page == "" &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user