UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

63 lines 7.5 kB
import { __decorate } from "tslib"; /** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ import { Directive, EventEmitter, Input, Output } from '@angular/core'; import { InputBoolean } from 'ng-zorro-antd/core/util'; import { NzResizeObserverFactory } from './resize-observer.service'; import * as i0 from "@angular/core"; import * as i1 from "./resize-observer.service"; export class NzResizeObserverDirective { subscribe() { this.unsubscribe(); this.currentSubscription = this.nzResizeObserver.observe(this.elementRef).subscribe(this.nzResizeObserve); } unsubscribe() { this.currentSubscription?.unsubscribe(); } constructor(nzResizeObserver, elementRef) { this.nzResizeObserver = nzResizeObserver; this.elementRef = elementRef; this.nzResizeObserve = new EventEmitter(); this.nzResizeObserverDisabled = false; this.currentSubscription = null; } ngAfterContentInit() { if (!this.currentSubscription && !this.nzResizeObserverDisabled) { this.subscribe(); } } ngOnDestroy() { this.unsubscribe(); } ngOnChanges(changes) { const { nzResizeObserve } = changes; if (nzResizeObserve) { if (this.nzResizeObserverDisabled) { this.unsubscribe(); } else { this.subscribe(); } } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NzResizeObserverDirective, deps: [{ token: i1.NzResizeObserver }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.4", type: NzResizeObserverDirective, isStandalone: true, selector: "[nzResizeObserver]", inputs: { nzResizeObserverDisabled: "nzResizeObserverDisabled" }, outputs: { nzResizeObserve: "nzResizeObserve" }, providers: [NzResizeObserverFactory], usesOnChanges: true, ngImport: i0 }); } } __decorate([ InputBoolean() ], NzResizeObserverDirective.prototype, "nzResizeObserverDisabled", void 0); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NzResizeObserverDirective, decorators: [{ type: Directive, args: [{ selector: '[nzResizeObserver]', standalone: true, providers: [NzResizeObserverFactory] }] }], ctorParameters: () => [{ type: i1.NzResizeObserver }, { type: i0.ElementRef }], propDecorators: { nzResizeObserve: [{ type: Output }], nzResizeObserverDisabled: [{ type: Input }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzaXplLW9ic2VydmVyLmRpcmVjdGl2ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL2NvbXBvbmVudHMvY2RrL3Jlc2l6ZS1vYnNlcnZlci9yZXNpemUtb2JzZXJ2ZXIuZGlyZWN0aXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7O0dBR0c7QUFFSCxPQUFPLEVBRUwsU0FBUyxFQUVULFlBQVksRUFDWixLQUFLLEVBR0wsTUFBTSxFQUVQLE1BQU0sZUFBZSxDQUFDO0FBSXZCLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUV2RCxPQUFPLEVBQW9CLHVCQUF1QixFQUFFLE1BQU0sMkJBQTJCLENBQUM7OztBQU90RixNQUFNLE9BQU8seUJBQXlCO0lBTTVCLFNBQVM7UUFDZixJQUFJLENBQUMsV0FBVyxFQUFFLENBQUM7UUFDbkIsSUFBSSxDQUFDLG1CQUFtQixHQUFHLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsZUFBZSxDQUFDLENBQUM7SUFDNUcsQ0FBQztJQUVPLFdBQVc7UUFDakIsSUFBSSxDQUFDLG1CQUFtQixFQUFFLFdBQVcsRUFBRSxDQUFDO0lBQzFDLENBQUM7SUFFRCxZQUNVLGdCQUFrQyxFQUNsQyxVQUFtQztRQURuQyxxQkFBZ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