mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
f1d8364a2e
bug fixes with new image loading and fullscreen mode
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import {Component, Input, OnChanges} from "@angular/core";
|
|
import {GridPhoto} from "../../grid/GridPhoto";
|
|
|
|
@Component({
|
|
selector: 'gallery-lightbox-photo',
|
|
styleUrls: ['app/gallery/lightbox/photo/photo.lightbox.gallery.component.css'],
|
|
templateUrl: 'app/gallery/lightbox/photo/photo.lightbox.gallery.component.html'
|
|
})
|
|
export class GalleryLightboxPhotoComponent implements OnChanges {
|
|
|
|
@Input() gridPhoto: GridPhoto;
|
|
|
|
public imageSize = {width: "auto", height: "100"};
|
|
|
|
imageLoaded: boolean = false;
|
|
|
|
constructor() {
|
|
}
|
|
|
|
ngOnChanges() {
|
|
|
|
this.imageLoaded = false;
|
|
this.setImageSize();
|
|
}
|
|
|
|
private setImageSize() {
|
|
if (!this.gridPhoto) {
|
|
return;
|
|
}
|
|
|
|
if (this.gridPhoto.photo.metadata.size.height > this.gridPhoto.photo.metadata.size.width) {
|
|
this.imageSize.height = "100";
|
|
this.imageSize.width = null;
|
|
} else {
|
|
this.imageSize.height = null;
|
|
this.imageSize.width = "100";
|
|
}
|
|
}
|
|
|
|
|
|
onImageLoad() {
|
|
this.imageLoaded = true;
|
|
}
|
|
|
|
onImageError() {
|
|
//TODO:handle error
|
|
console.error("cant load image");
|
|
}
|
|
|
|
public showThumbnail(): boolean {
|
|
return this.gridPhoto && !this.imageLoaded &&
|
|
(this.gridPhoto.isThumbnailAvailable() || this.gridPhoto.isReplacementThumbnailAvailable());
|
|
}
|
|
|
|
public thumbnailPath(): string {
|
|
if (this.gridPhoto.isThumbnailAvailable() === true)
|
|
return this.gridPhoto.getThumbnailPath();
|
|
|
|
if (this.gridPhoto.isReplacementThumbnailAvailable() === true)
|
|
return this.gridPhoto.getReplacementThumbnailPath();
|
|
return null
|
|
}
|
|
|
|
}
|
|
|