2017-03-26 04:59:30 +08:00
|
|
|
import {
|
2017-06-11 04:32:56 +08:00
|
|
|
ChangeDetectorRef,
|
|
|
|
Component,
|
|
|
|
ElementRef,
|
|
|
|
EventEmitter,
|
|
|
|
HostListener,
|
2017-07-10 04:00:42 +08:00
|
|
|
OnDestroy,
|
2017-06-11 04:32:56 +08:00
|
|
|
Output,
|
|
|
|
QueryList,
|
|
|
|
ViewChild
|
2017-03-26 04:59:30 +08:00
|
|
|
} from "@angular/core";
|
2016-12-28 03:55:51 +08:00
|
|
|
import {PhotoDTO} from "../../../../common/entities/PhotoDTO";
|
2016-12-27 06:36:38 +08:00
|
|
|
import {GalleryPhotoComponent} from "../grid/photo/photo.grid.gallery.component";
|
2016-05-01 03:36:24 +08:00
|
|
|
import {Dimension} from "../../model/IRenderable";
|
2016-07-06 18:53:49 +08:00
|
|
|
import {FullScreenService} from "../fullscreen.service";
|
2017-03-26 04:59:30 +08:00
|
|
|
import {OverlayService} from "../overlay.service";
|
|
|
|
import {Subscription} from "rxjs";
|
2017-07-16 05:54:17 +08:00
|
|
|
import {animate, AnimationBuilder, AnimationPlayer, style} from "@angular/animations";
|
2017-07-11 04:00:22 +08:00
|
|
|
import {GalleryLightboxPhotoComponent} from "./photo/photo.lightbox.gallery.component";
|
2017-07-12 02:23:25 +08:00
|
|
|
import {Observable} from "rxjs/Observable";
|
2016-05-01 00:01:54 +08:00
|
|
|
|
|
|
|
@Component({
|
2017-06-11 04:32:56 +08:00
|
|
|
selector: 'gallery-lightbox',
|
|
|
|
styleUrls: ['./lightbox.gallery.component.css'],
|
2017-07-11 04:00:22 +08:00
|
|
|
templateUrl: './lightbox.gallery.component.html'
|
2016-05-01 00:01:54 +08:00
|
|
|
})
|
2017-07-10 04:00:42 +08:00
|
|
|
export class GalleryLightboxComponent implements OnDestroy {
|
2017-07-18 00:30:16 +08:00
|
|
|
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
@Output('onLastElement') onLastElement = new EventEmitter();
|
2017-07-11 04:00:22 +08:00
|
|
|
@ViewChild("photo") photoElement: GalleryLightboxPhotoComponent;
|
|
|
|
@ViewChild("lightbox") lightboxElement: ElementRef;
|
2016-05-01 00:01:54 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
public navigation = {hasPrev: true, hasNext: true};
|
|
|
|
public blackCanvasOpacity: any = 0;
|
2016-07-04 22:58:10 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
public activePhoto: GalleryPhotoComponent;
|
|
|
|
private gridPhotoQL: QueryList<GalleryPhotoComponent>;
|
2016-05-01 00:01:54 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
public visible = false;
|
|
|
|
private changeSubscription: Subscription = null;
|
2017-07-12 02:23:25 +08:00
|
|
|
private timer: Observable<number>;
|
|
|
|
private timerSub: Subscription;
|
|
|
|
public playBackState: number = 0;
|
|
|
|
public controllersDimmed = true;
|
|
|
|
public controllersVisible = true;
|
2017-07-10 04:00:42 +08:00
|
|
|
|
|
|
|
public infoPanelVisible = false;
|
|
|
|
public infoPanelWidth = 0;
|
2017-07-17 02:49:12 +08:00
|
|
|
public animating = false;
|
2016-05-01 03:36:24 +08:00
|
|
|
|
2016-07-06 18:53:49 +08:00
|
|
|
|
2017-07-11 04:00:22 +08:00
|
|
|
constructor(public fullScreenService: FullScreenService,
|
|
|
|
private changeDetector: ChangeDetectorRef, private overlayService: OverlayService,
|
|
|
|
private _builder: AnimationBuilder) {
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-05-01 00:33:07 +08:00
|
|
|
|
2017-07-12 02:23:25 +08:00
|
|
|
ngOnInit(): void {
|
|
|
|
this.timer = Observable.timer(1000, 2000);
|
|
|
|
}
|
2016-05-01 03:36:24 +08:00
|
|
|
|
2017-07-10 04:00:42 +08:00
|
|
|
ngOnDestroy(): void {
|
2017-07-12 02:23:25 +08:00
|
|
|
this.pause();
|
2017-07-10 04:00:42 +08:00
|
|
|
if (this.changeSubscription != null) {
|
|
|
|
this.changeSubscription.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//noinspection JSUnusedGlobalSymbols
|
2017-06-11 04:32:56 +08:00
|
|
|
@HostListener('window:resize', ['$event'])
|
|
|
|
onResize() {
|
|
|
|
if (this.activePhoto) {
|
2017-07-11 04:00:22 +08:00
|
|
|
this.animateLightbox();
|
2017-06-11 04:32:56 +08:00
|
|
|
this.updateActivePhoto(this.activePhotoId);
|
2016-05-01 00:01:54 +08:00
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-05-01 00:01:54 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
public nextImage() {
|
|
|
|
if (this.activePhotoId + 1 < this.gridPhotoQL.length) {
|
|
|
|
this.showPhoto(this.activePhotoId + 1);
|
|
|
|
if (this.activePhotoId + 3 >= this.gridPhotoQL.length) {
|
|
|
|
this.onLastElement.emit({}); //trigger to render more photos if there are
|
|
|
|
}
|
|
|
|
return;
|
2016-05-13 05:00:38 +08:00
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-05-13 05:00:38 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
public prevImage() {
|
2017-07-12 02:23:25 +08:00
|
|
|
this.pause();
|
2017-06-11 04:32:56 +08:00
|
|
|
if (this.activePhotoId > 0) {
|
|
|
|
this.showPhoto(this.activePhotoId - 1);
|
|
|
|
return;
|
2016-05-13 05:00:38 +08:00
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-05-13 05:00:38 +08:00
|
|
|
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
activePhotoId: number = null;
|
|
|
|
|
2017-07-11 04:00:22 +08:00
|
|
|
private showPhoto(photoIndex: number, resize: boolean = true) {
|
2017-06-11 04:32:56 +08:00
|
|
|
this.activePhoto = null;
|
|
|
|
this.changeDetector.detectChanges();
|
2017-07-11 04:00:22 +08:00
|
|
|
this.updateActivePhoto(photoIndex, resize);
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
|
|
|
|
2017-07-11 04:00:22 +08:00
|
|
|
private updateActivePhoto(photoIndex: number, resize: boolean = true) {
|
2017-06-11 04:32:56 +08:00
|
|
|
let pcList = this.gridPhotoQL.toArray();
|
|
|
|
|
|
|
|
|
|
|
|
if (photoIndex < 0 || photoIndex > this.gridPhotoQL.length) {
|
|
|
|
throw new Error("Can't find the photo");
|
|
|
|
}
|
|
|
|
this.activePhotoId = photoIndex;
|
|
|
|
this.activePhoto = pcList[photoIndex];
|
|
|
|
|
2017-07-11 04:00:22 +08:00
|
|
|
if (resize) {
|
|
|
|
this.animatePhoto(this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo));
|
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
this.navigation.hasPrev = photoIndex > 0;
|
|
|
|
this.navigation.hasNext = photoIndex + 1 < pcList.length;
|
|
|
|
|
|
|
|
let to = this.activePhoto.getDimension();
|
|
|
|
|
|
|
|
//if target image out of screen -> scroll to there
|
2017-07-17 02:49:12 +08:00
|
|
|
if (this.getBodyScrollTop() > to.top || this.getBodyScrollTop() + this.getPhotoFrameHeight() < to.top) {
|
2017-06-11 04:32:56 +08:00
|
|
|
this.setBodyScrollTop(to.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-07-11 04:00:22 +08:00
|
|
|
startPhotoDimension: Dimension = <Dimension>{top: 0, left: 0, width: 0, height: 0};
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
public show(photo: PhotoDTO) {
|
2017-07-12 02:23:25 +08:00
|
|
|
this.controllersVisible = true;
|
|
|
|
this.showControls();
|
2017-06-11 04:32:56 +08:00
|
|
|
this.visible = true;
|
|
|
|
let selectedPhoto = this.findPhotoComponent(photo);
|
|
|
|
if (selectedPhoto === null) {
|
|
|
|
throw new Error("Can't find Photo");
|
|
|
|
}
|
|
|
|
|
2017-07-11 04:00:22 +08:00
|
|
|
const lightboxDimension = selectedPhoto.getDimension();
|
|
|
|
lightboxDimension.top -= this.getBodyScrollTop();
|
2017-07-16 05:54:17 +08:00
|
|
|
this.animating = true;
|
|
|
|
this.animatePhoto(selectedPhoto.getDimension(), this.calcLightBoxPhotoDimension(selectedPhoto.gridPhoto.photo)).onDone(() => {
|
|
|
|
this.animating = false;
|
|
|
|
});
|
2017-07-11 04:00:22 +08:00
|
|
|
this.animateLightbox(
|
|
|
|
lightboxDimension,
|
|
|
|
<Dimension>{
|
2017-06-11 04:32:56 +08:00
|
|
|
top: 0,
|
|
|
|
left: 0,
|
2017-07-17 02:49:12 +08:00
|
|
|
width: this.getPhotoFrameWidth(),
|
|
|
|
height: this.getPhotoFrameHeight()
|
2017-07-11 04:00:22 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.blackCanvasOpacity = 0;
|
|
|
|
this.startPhotoDimension = selectedPhoto.getDimension();
|
|
|
|
//disable scroll
|
|
|
|
this.overlayService.showOverlay();
|
|
|
|
this.blackCanvasOpacity = 1.0;
|
|
|
|
this.showPhoto(this.gridPhotoQL.toArray().indexOf(selectedPhoto), false);
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public hide() {
|
2017-07-12 02:23:25 +08:00
|
|
|
this.controllersVisible = false;
|
2017-06-11 04:32:56 +08:00
|
|
|
this.fullScreenService.exitFullScreen();
|
2017-07-13 00:31:19 +08:00
|
|
|
this.pause();
|
2017-06-11 04:32:56 +08:00
|
|
|
|
2017-07-16 05:54:17 +08:00
|
|
|
this.animating = true;
|
2017-07-11 04:00:22 +08:00
|
|
|
const lightboxDimension = this.activePhoto.getDimension();
|
|
|
|
lightboxDimension.top -= this.getBodyScrollTop();
|
2017-06-11 04:32:56 +08:00
|
|
|
this.blackCanvasOpacity = 0;
|
2017-07-11 04:00:22 +08:00
|
|
|
|
|
|
|
this.animatePhoto(this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo), this.activePhoto.getDimension());
|
|
|
|
this.animateLightbox(<Dimension>{
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
2017-07-17 02:49:12 +08:00
|
|
|
width: this.getPhotoFrameWidth(),
|
|
|
|
height: this.getPhotoFrameHeight()
|
2017-07-16 05:54:17 +08:00
|
|
|
}, lightboxDimension).onDone(() => {
|
2017-07-11 04:00:22 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
this.visible = false;
|
|
|
|
this.activePhoto = null;
|
|
|
|
this.overlayService.hideOverlay();
|
2017-07-16 05:54:17 +08:00
|
|
|
});
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
|
2017-07-11 04:41:30 +08:00
|
|
|
this.hideInfoPanel(false);
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
|
|
|
|
2017-07-16 05:54:17 +08:00
|
|
|
|
|
|
|
animatePhoto(from: Dimension, to: Dimension = from): AnimationPlayer {
|
|
|
|
const elem = this._builder.build([
|
2017-07-11 04:00:22 +08:00
|
|
|
style(<any>Dimension.toString(from)),
|
|
|
|
animate(300,
|
|
|
|
style(<any>Dimension.toString(to)))
|
|
|
|
])
|
2017-07-16 05:54:17 +08:00
|
|
|
.create(this.photoElement.elementRef.nativeElement);
|
|
|
|
elem.play();
|
|
|
|
return elem;
|
2017-07-11 04:00:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
animateLightbox(from: Dimension = <Dimension>{
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
2017-07-17 02:49:12 +08:00
|
|
|
width: this.getPhotoFrameWidth(),
|
|
|
|
height: this.getPhotoFrameHeight()
|
2017-07-16 05:54:17 +08:00
|
|
|
}, to: Dimension = from): AnimationPlayer {
|
|
|
|
const elem = this._builder.build([
|
2017-07-11 04:00:22 +08:00
|
|
|
style(<any>Dimension.toString(from)),
|
|
|
|
animate(300,
|
|
|
|
style(<any>Dimension.toString(to)))
|
|
|
|
])
|
2017-07-16 05:54:17 +08:00
|
|
|
.create(this.lightboxElement.nativeElement);
|
|
|
|
elem.play();
|
|
|
|
return elem;
|
2017-07-11 04:00:22 +08:00
|
|
|
}
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
|
|
|
|
setGridPhotoQL(value: QueryList<GalleryPhotoComponent>) {
|
|
|
|
if (this.changeSubscription != null) {
|
|
|
|
this.changeSubscription.unsubscribe();
|
|
|
|
}
|
|
|
|
this.gridPhotoQL = value;
|
|
|
|
this.changeSubscription = this.gridPhotoQL.changes.subscribe(() => {
|
|
|
|
if (this.activePhotoId != null && this.gridPhotoQL.length > this.activePhotoId) {
|
|
|
|
this.updateActivePhoto(this.activePhotoId);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-07-11 04:00:22 +08:00
|
|
|
private findPhotoComponent(photo: any): GalleryPhotoComponent {
|
2017-06-11 04:32:56 +08:00
|
|
|
let galleryPhotoComponents = this.gridPhotoQL.toArray();
|
|
|
|
for (let i = 0; i < galleryPhotoComponents.length; i++) {
|
|
|
|
if (galleryPhotoComponents[i].gridPhoto.photo == photo) {
|
|
|
|
return galleryPhotoComponents[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//noinspection JSUnusedGlobalSymbols
|
|
|
|
@HostListener('window:keydown', ['$event'])
|
|
|
|
onKeyPress(e: KeyboardEvent) {
|
|
|
|
if (this.visible != true) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let event: KeyboardEvent = window.event ? <any>window.event : e;
|
|
|
|
switch (event.keyCode) {
|
|
|
|
case 37:
|
|
|
|
if (this.activePhotoId > 0) {
|
|
|
|
this.prevImage();
|
2016-12-30 18:58:04 +08:00
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
break;
|
|
|
|
case 39:
|
|
|
|
if (this.activePhotoId < this.gridPhotoQL.length - 1) {
|
|
|
|
this.nextImage();
|
2017-03-26 04:59:30 +08:00
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
break;
|
|
|
|
case 27: //escape
|
|
|
|
this.hide();
|
|
|
|
break;
|
2016-07-05 04:10:30 +08:00
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-07-05 04:10:30 +08:00
|
|
|
|
2017-07-10 04:00:42 +08:00
|
|
|
iPvisibilityTimer = null;
|
|
|
|
|
|
|
|
public toggleInfoPanel() {
|
|
|
|
|
|
|
|
|
|
|
|
if (this.infoPanelWidth != 400) {
|
|
|
|
this.showInfoPanel();
|
|
|
|
} else {
|
|
|
|
this.hideInfoPanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
showInfoPanel() {
|
|
|
|
this.infoPanelVisible = true;
|
2017-07-11 04:00:22 +08:00
|
|
|
|
|
|
|
const starPhotoPos = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo);
|
|
|
|
this.infoPanelWidth = 400;
|
|
|
|
const endPhotoPos = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo);
|
|
|
|
this.animatePhoto(starPhotoPos, endPhotoPos);
|
|
|
|
this.animateLightbox(<Dimension>{
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
2017-07-17 02:49:12 +08:00
|
|
|
width: this.getPhotoFrameWidth() + 400,
|
|
|
|
height: this.getPhotoFrameHeight()
|
2017-07-11 04:00:22 +08:00
|
|
|
},
|
|
|
|
<Dimension>{
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
2017-07-17 02:49:12 +08:00
|
|
|
width: this.getPhotoFrameWidth(),
|
|
|
|
height: this.getPhotoFrameHeight()
|
2017-07-11 04:00:22 +08:00
|
|
|
});
|
2017-07-10 04:00:42 +08:00
|
|
|
if (this.iPvisibilityTimer != null) {
|
|
|
|
clearTimeout(this.iPvisibilityTimer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-11 04:41:30 +08:00
|
|
|
hideInfoPanel(animate: boolean = true) {
|
2017-07-10 04:00:42 +08:00
|
|
|
this.iPvisibilityTimer = setTimeout(() => {
|
|
|
|
this.iPvisibilityTimer = null;
|
|
|
|
this.infoPanelVisible = false;
|
|
|
|
}, 1000);
|
2016-05-01 00:01:54 +08:00
|
|
|
|
2017-07-11 04:00:22 +08:00
|
|
|
const starPhotoPos = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo);
|
|
|
|
this.infoPanelWidth = 0;
|
|
|
|
const endPhotoPos = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo);
|
2017-07-11 04:41:30 +08:00
|
|
|
if (animate) {
|
|
|
|
this.animatePhoto(starPhotoPos, endPhotoPos);
|
|
|
|
}
|
|
|
|
if (animate) {
|
|
|
|
this.animateLightbox(<Dimension>{
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
2017-07-17 02:49:12 +08:00
|
|
|
width: this.getPhotoFrameWidth() - 400,
|
|
|
|
height: this.getPhotoFrameHeight()
|
2017-07-11 04:41:30 +08:00
|
|
|
},
|
|
|
|
<Dimension>{
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
2017-07-17 02:49:12 +08:00
|
|
|
width: this.getPhotoFrameWidth(),
|
|
|
|
height: this.getPhotoFrameHeight()
|
2017-07-11 04:41:30 +08:00
|
|
|
});
|
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-05-01 00:01:54 +08:00
|
|
|
|
2016-05-01 03:36:24 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private getBodyScrollTop(): number {
|
|
|
|
return window.scrollY;
|
|
|
|
}
|
2016-06-16 22:24:47 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private setBodyScrollTop(value: number) {
|
|
|
|
window.scrollTo(window.scrollX, value);
|
|
|
|
}
|
2016-05-01 03:36:24 +08:00
|
|
|
|
2017-07-17 02:49:12 +08:00
|
|
|
private getPhotoFrameWidth() {
|
2017-07-10 04:00:42 +08:00
|
|
|
return Math.max(window.innerWidth - this.infoPanelWidth, 0);
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-07-06 18:53:49 +08:00
|
|
|
|
2017-07-17 02:49:12 +08:00
|
|
|
private getPhotoFrameHeight() {
|
2017-06-11 04:32:56 +08:00
|
|
|
return window.innerHeight;
|
|
|
|
}
|
2016-12-30 18:58:04 +08:00
|
|
|
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private calcLightBoxPhotoDimension(photo: PhotoDTO): Dimension {
|
|
|
|
let width = 0;
|
|
|
|
let height = 0;
|
2017-07-17 02:49:12 +08:00
|
|
|
const photoAspect = photo.metadata.size.width / photo.metadata.size.height;
|
|
|
|
const windowAspect = this.getPhotoFrameWidth() / this.getPhotoFrameHeight();
|
|
|
|
if (photoAspect < windowAspect) {
|
|
|
|
width = Math.round(photo.metadata.size.width * (this.getPhotoFrameHeight() / photo.metadata.size.height));
|
|
|
|
height = this.getPhotoFrameHeight();
|
2017-06-11 04:32:56 +08:00
|
|
|
} else {
|
2017-07-17 02:49:12 +08:00
|
|
|
width = this.getPhotoFrameWidth();
|
|
|
|
height = Math.round(photo.metadata.size.height * (this.getPhotoFrameWidth() / photo.metadata.size.width));
|
2016-05-01 03:36:24 +08:00
|
|
|
}
|
2017-07-17 02:49:12 +08:00
|
|
|
let top = (this.getPhotoFrameHeight() / 2 - height / 2);
|
|
|
|
let left = (this.getPhotoFrameWidth() / 2 - width / 2);
|
2016-05-01 03:36:24 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
return <Dimension>{top: top, left: left, width: width, height: height};
|
|
|
|
}
|
2017-07-12 02:23:25 +08:00
|
|
|
|
|
|
|
visibilityTimer = null;
|
|
|
|
|
|
|
|
@HostListener('mousemove')
|
|
|
|
onMousemove() {
|
|
|
|
this.showControls();
|
|
|
|
}
|
|
|
|
|
|
|
|
private showControls() {
|
|
|
|
this.controllersDimmed = true;
|
|
|
|
if (this.visibilityTimer != null) {
|
|
|
|
clearTimeout(this.visibilityTimer);
|
|
|
|
}
|
|
|
|
this.visibilityTimer = setTimeout(this.hideControls, 2000);
|
|
|
|
}
|
|
|
|
|
|
|
|
private hideControls = () => {
|
|
|
|
|
|
|
|
this.controllersDimmed = false;
|
|
|
|
};
|
|
|
|
|
2017-07-17 02:49:12 +08:00
|
|
|
|
2017-07-12 02:23:25 +08:00
|
|
|
public pause() {
|
|
|
|
if (this.timerSub != null) {
|
|
|
|
this.timerSub.unsubscribe();
|
|
|
|
}
|
|
|
|
this.playBackState = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public play() {
|
|
|
|
this.pause();
|
|
|
|
this.timerSub = this.timer.filter(t => t % 2 == 0).subscribe(() => {
|
|
|
|
if (this.navigation.hasNext) {
|
|
|
|
this.nextImage();
|
|
|
|
} else {
|
|
|
|
this.showPhoto(0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.playBackState = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public fastForward() {
|
|
|
|
this.pause();
|
|
|
|
this.timerSub = this.timer.subscribe(() => {
|
|
|
|
if (this.navigation.hasNext) {
|
|
|
|
this.nextImage();
|
|
|
|
} else {
|
|
|
|
this.showPhoto(0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.playBackState = 2;
|
|
|
|
}
|
2016-05-01 00:01:54 +08:00
|
|
|
}
|
|
|
|
|