mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
lightbox next, prev button bugfix
This commit is contained in:
parent
a7a8e42490
commit
d82c9eec93
@ -36,18 +36,12 @@ export class GalleryLightboxComponent {
|
||||
let pcList = this.gridPhotoQL.toArray();
|
||||
for (let i = 0; i < pcList.length; i++) {
|
||||
if (pcList[i] === this.activePhoto && i + 1 < pcList.length) {
|
||||
this.activePhoto = pcList[i + 1];
|
||||
this.navigation.hasPrev = true;
|
||||
|
||||
this.navigation.hasNext = i + 2 < pcList.length;
|
||||
|
||||
this.showPhoto(pcList[i + 1]);
|
||||
|
||||
if (i + 3 === pcList.length) {
|
||||
this.onLastElement.emit({}); //trigger to render more photos if there are
|
||||
}
|
||||
|
||||
this.photoDimension = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -57,29 +51,35 @@ export class GalleryLightboxComponent {
|
||||
let pcList = this.gridPhotoQL.toArray();
|
||||
for (let i = 0; i < pcList.length; i++) {
|
||||
if (pcList[i] === this.activePhoto && i > 0) {
|
||||
this.activePhoto = pcList[i - 1];
|
||||
this.navigation.hasNext = true;
|
||||
this.navigation.hasPrev = i - 1 > 0;
|
||||
|
||||
this.photoDimension = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo);
|
||||
|
||||
|
||||
this.showPhoto(pcList[i - 1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private showPhoto(photoComponent:GalleryPhotoComponent) {
|
||||
let pcList = this.gridPhotoQL.toArray();
|
||||
|
||||
let index = pcList.indexOf(photoComponent);
|
||||
if (index == -1) {
|
||||
throw new Error("Can't find the photo");
|
||||
}
|
||||
|
||||
this.navigation.hasPrev = index > 0;
|
||||
this.navigation.hasNext = index + 1 < pcList.length;
|
||||
this.activePhoto = photoComponent;
|
||||
this.photoDimension = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo);
|
||||
}
|
||||
|
||||
public show(photo:Photo) {
|
||||
let selectedPhoto = this.findPhotoComponent(photo);
|
||||
if (selectedPhoto === null) {
|
||||
throw new Error("Can't find Photo");
|
||||
}
|
||||
|
||||
this.showPhoto(selectedPhoto);
|
||||
this.dom.setStyle(this.dom.query('body'), 'overflow', 'hidden');
|
||||
this.activePhoto = selectedPhoto;
|
||||
this.photoDimension = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo);
|
||||
|
||||
}
|
||||
|
||||
public hide() {
|
||||
@ -98,14 +98,12 @@ export class GalleryLightboxComponent {
|
||||
|
||||
private findPhotoComponent(photo) {
|
||||
let galleryPhotoComponents = this.gridPhotoQL.toArray();
|
||||
let selectedPhoto:GalleryPhotoComponent = null;
|
||||
for (let i = 0; i < galleryPhotoComponents.length; i++) {
|
||||
if (galleryPhotoComponents[i].gridPhoto.photo == photo) {
|
||||
selectedPhoto = galleryPhotoComponents[i];
|
||||
break;
|
||||
return galleryPhotoComponents[i];
|
||||
}
|
||||
}
|
||||
return selectedPhoto;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user