1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/gallery/fullscreen.service.ts
2016-07-06 12:53:49 +02:00

44 lines
1.2 KiB
TypeScript

///<reference path="../../browser.d.ts"/>
import {Injectable} from "@angular/core";
@Injectable()
export class FullScreenService {
public isFullScreenEnabled():boolean {
return !!(document.fullscreenElement || document['mozFullScreenElement'] || document.webkitFullscreenElement);
}
public showFullScreen(element:any) {
if (this.isFullScreenEnabled()) {
return;
}
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}
public exitFullScreen() {
if (!this.isFullScreenEnabled()) {
return;
}
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document['mozCancelFullScreen']) {
document['mozCancelFullScreen']();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}