- ();
constructor(public elementRef: ElementRef,
+ private renderer: Renderer2,
+ private sanitizer: DomSanitizer,
private viewContainerRef: ViewContainerRef,
private overlay: Overlay) {
}
@@ -92,10 +101,33 @@ export class FullscreenDirective implements OnChanges, OnDestroy {
this.overlayRef = this.overlay.create(config);
this.overlayRef.attach(new EmptyPortal());
+ if (this.fullscreenBackgroundStyle) {
+ for (const key of Object.keys(this.fullscreenBackgroundStyle)) {
+ this.setStyle(this.overlayRef.overlayElement, key, this.fullscreenBackgroundStyle[key]);
+ }
+ }
+ if (this.fullscreenBackgroundImage) {
+ this.setStyle(this.overlayRef.overlayElement, 'backgroundImage', this.fullscreenBackgroundImage);
+ }
this.overlayRef.overlayElement.appendChild( targetElement );
this.fullscreenChanged.emit(true);
}
+ private setStyle(el: any, nameAndUnit: string, value: any): void {
+ const [name, unit] = nameAndUnit.split('.');
+ let renderValue: string|null =
+ this.sanitizer.sanitize(SecurityContext.STYLE, value as{} | string);
+ if (renderValue != null) {
+ renderValue = renderValue.toString();
+ }
+ renderValue = renderValue != null && unit ? `${renderValue}${unit}` : renderValue;
+ if (renderValue != null) {
+ this.renderer.setStyle(this.overlayRef.overlayElement, name, renderValue);
+ } else {
+ this.renderer.removeStyle(this.overlayRef.overlayElement, name);
+ }
+ }
+
exitFullscreen() {
const targetElement: HTMLElement = this.fullscreenElement || this.elementRef.nativeElement;
if (this.parentElement) {