UNPKG

ngx-x-browser-svg-mask

Version:

Angular attribute directive that handles cross browser considerations for applying SVG image masks in the DOM.

97 lines (91 loc) 4.06 kB
import * as i0 from '@angular/core'; import { HostBinding, Input, Directive, NgModule } from '@angular/core'; class NgxXBrowserSVGMaskDirective { /** * Host binding to apply the svg image element node type attribute. */ get svgMaskImage() { if (this.el.nativeElement.nodeName.toLowerCase() === 'image') { return this.maskImage; } else { return undefined; } } /** * Host binding to apply the standard css style to non-image type element nodes. */ get cssMaskImage() { if (this.el.nativeElement.nodeName.toLowerCase() !== 'image') { return this.maskImage; } else { return undefined; } } /** * Host binding to apply the webkit style to non-image type element nodes. */ get cssWebkitMaskImage() { if (this.el.nativeElement.nodeName.toLowerCase() !== 'image') { return this.maskImage; } else { return undefined; } } /** * Read only property that calculates the direct url path for the image mask that we want to use. * * @return The mask with full url route designated. */ get maskImage() { return 'url(' + window.location.pathname.slice(1) + window.location.search + this.mask + ')'; } constructor(el) { this.el = el; this.mask = ''; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: NgxXBrowserSVGMaskDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.7", type: NgxXBrowserSVGMaskDirective, isStandalone: false, selector: "[ngxSVGMask]", inputs: { mask: ["ngxSVGMask", "mask"] }, host: { properties: { "attr.mask": "this.svgMaskImage", "style.mask-image": "this.cssMaskImage", "style.-webkit-mask-image": "this.cssWebkitMaskImage" } }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: NgxXBrowserSVGMaskDirective, decorators: [{ type: Directive, args: [{ selector: '[ngxSVGMask]', standalone: false, }] }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { mask: [{ type: Input, args: ['ngxSVGMask'] }], svgMaskImage: [{ type: HostBinding, args: ['attr.mask'] }], cssMaskImage: [{ type: HostBinding, args: ['style.mask-image'] }], cssWebkitMaskImage: [{ type: HostBinding, args: ['style.-webkit-mask-image'] }] } }); class NgxXBrowserSVGMaskModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: NgxXBrowserSVGMaskModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.7", ngImport: i0, type: NgxXBrowserSVGMaskModule, declarations: [NgxXBrowserSVGMaskDirective], exports: [NgxXBrowserSVGMaskDirective] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: NgxXBrowserSVGMaskModule }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: NgxXBrowserSVGMaskModule, decorators: [{ type: NgModule, args: [{ declarations: [NgxXBrowserSVGMaskDirective], imports: [], exports: [NgxXBrowserSVGMaskDirective], }] }] }); /* * Public API Surface of ngx-x-browser-svg-mask */ /** * Generated bundle index. Do not edit. */ export { NgxXBrowserSVGMaskDirective, NgxXBrowserSVGMaskModule }; //# sourceMappingURL=ngx-x-browser-svg-mask.mjs.map