UNPKG

ng-zorro-antd-yj

Version:

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

417 lines 34.6 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import * as tslib_1 from "tslib"; import { DOCUMENT } from '@angular/common'; import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Inject, Input, Output, ViewChild, ViewEncapsulation } from '@angular/core'; import { NzScrollService } from '../core/scroll/nz-scroll.service'; import { shallowEqual } from '../core/util/check'; import { toNumber } from '../core/util/convert'; import { throttleByAnimationFrameDecorator } from '../core/util/throttleByAnimationFrame'; export class NzAffixComponent { // tslint:disable-next-line:no-any /** * @param {?} _el * @param {?} scrollSrv * @param {?} doc */ constructor(_el, scrollSrv, doc) { this.scrollSrv = scrollSrv; this.doc = doc; this.nzChange = new EventEmitter(); this.events = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load']; this._target = window; this.placeholderNode = _el.nativeElement; } /** * @param {?} value * @return {?} */ set nzTarget(value) { this.clearEventListeners(); this._target = typeof value === 'string' ? this.doc.querySelector(value) : value || window; this.setTargetEventListeners(); this.updatePosition((/** @type {?} */ ({}))); } /** * @param {?} value * @return {?} */ set nzOffsetTop(value) { if (value === undefined || value === null) { return; } this._offsetTop = toNumber(value, null); this.updatePosition((/** @type {?} */ ({}))); } /** * @return {?} */ get nzOffsetTop() { return this._offsetTop; } /** * @param {?} value * @return {?} */ set nzOffsetBottom(value) { if (typeof value === 'undefined') { return; } this._offsetBottom = toNumber(value, null); this.updatePosition((/** @type {?} */ ({}))); } /** * @return {?} */ ngOnInit() { this.timeout = setTimeout((/** * @return {?} */ () => { this.setTargetEventListeners(); this.updatePosition((/** @type {?} */ ({}))); })); } /** * @return {?} */ ngOnDestroy() { this.clearEventListeners(); clearTimeout(this.timeout); // tslint:disable-next-line:no-any ((/** @type {?} */ (this.updatePosition))).cancel(); } /** * @param {?} element * @param {?} target * @return {?} */ getOffset(element, target) { /** @type {?} */ const elemRect = element.getBoundingClientRect(); /** @type {?} */ const targetRect = this.getTargetRect(target); /** @type {?} */ const scrollTop = this.scrollSrv.getScroll(target, true); /** @type {?} */ const scrollLeft = this.scrollSrv.getScroll(target, false); /** @type {?} */ const docElem = this.doc.body; /** @type {?} */ const clientTop = docElem.clientTop || 0; /** @type {?} */ const clientLeft = docElem.clientLeft || 0; return { top: elemRect.top - targetRect.top + scrollTop - clientTop, left: elemRect.left - targetRect.left + scrollLeft - clientLeft, width: elemRect.width, height: elemRect.height }; } /** * @private * @return {?} */ setTargetEventListeners() { this.clearEventListeners(); this.events.forEach((/** * @param {?} eventName * @return {?} */ (eventName) => { this._target.addEventListener(eventName, this.updatePosition, false); })); } /** * @private * @return {?} */ clearEventListeners() { this.events.forEach((/** * @param {?} eventName * @return {?} */ eventName => { this._target.removeEventListener(eventName, this.updatePosition, false); })); } /** * @private * @param {?} target * @return {?} */ getTargetRect(target) { return target !== window ? ((/** @type {?} */ (target))).getBoundingClientRect() : ((/** @type {?} */ ({ top: 0, left: 0, bottom: 0 }))); } /** * @private * @param {?=} affixStyle * @return {?} */ genStyle(affixStyle) { if (!affixStyle) { return ''; } return Object.keys(affixStyle) .map((/** * @param {?} key * @return {?} */ key => { /** @type {?} */ const val = affixStyle[key]; return `${key}:${typeof val === 'string' ? val : val + 'px'}`; })) .join(';'); } /** * @private * @param {?} e * @param {?=} affixStyle * @return {?} */ setAffixStyle(e, affixStyle) { /** @type {?} */ const originalAffixStyle = this.affixStyle; /** @type {?} */ const isWindow = this._target === window; if (e.type === 'scroll' && originalAffixStyle && affixStyle && isWindow) { return; } if (shallowEqual(originalAffixStyle, affixStyle)) { return; } /** @type {?} */ const fixed = !!affixStyle; /** @type {?} */ const wrapEl = (/** @type {?} */ (this.fixedEl.nativeElement)); wrapEl.style.cssText = this.genStyle(affixStyle); this.affixStyle = affixStyle; /** @type {?} */ const cls = 'ant-affix'; if (fixed) { wrapEl.classList.add(cls); } else { wrapEl.classList.remove(cls); } if ((affixStyle && !originalAffixStyle) || (!affixStyle && originalAffixStyle)) { this.nzChange.emit(fixed); } } /** * @private * @param {?=} placeholderStyle * @return {?} */ setPlaceholderStyle(placeholderStyle) { /** @type {?} */ const originalPlaceholderStyle = this.placeholderStyle; if (shallowEqual(placeholderStyle, originalPlaceholderStyle)) { return; } this.placeholderNode.style.cssText = this.genStyle(placeholderStyle); this.placeholderStyle = placeholderStyle; } /** * @private * @param {?} e * @return {?} */ syncPlaceholderStyle(e) { if (!this.affixStyle) { return; } this.placeholderNode.style.cssText = ''; this.placeholderStyle = undefined; /** @type {?} */ const styleObj = { width: this.placeholderNode.offsetWidth, height: this.fixedEl.nativeElement.offsetHeight }; this.setAffixStyle(e, Object.assign({}, this.affixStyle, styleObj)); this.setPlaceholderStyle(styleObj); } /** * @param {?} e * @return {?} */ updatePosition(e) { /** @type {?} */ const targetNode = this._target; // Backwards support /** @type {?} */ let offsetTop = this.nzOffsetTop; /** @type {?} */ const scrollTop = this.scrollSrv.getScroll(targetNode, true); /** @type {?} */ const elemOffset = this.getOffset(this.placeholderNode, targetNode); /** @type {?} */ const fixedNode = (/** @type {?} */ (this.fixedEl.nativeElement)); /** @type {?} */ const elemSize = { width: fixedNode.offsetWidth, height: fixedNode.offsetHeight }; /** @type {?} */ const offsetMode = { top: false, bottom: false }; // Default to `offsetTop=0`. if (typeof offsetTop !== 'number' && typeof this._offsetBottom !== 'number') { offsetMode.top = true; offsetTop = 0; } else { offsetMode.top = typeof offsetTop === 'number'; offsetMode.bottom = typeof this._offsetBottom === 'number'; } /** @type {?} */ const targetRect = this.getTargetRect(targetNode); /** @type {?} */ const targetInnerHeight = ((/** @type {?} */ (targetNode))).innerHeight || ((/** @type {?} */ (targetNode))).clientHeight; if (scrollTop >= elemOffset.top - ((/** @type {?} */ (offsetTop))) && offsetMode.top) { /** @type {?} */ const width = elemOffset.width; /** @type {?} */ const top = targetRect.top + ((/** @type {?} */ (offsetTop))); this.setAffixStyle(e, { position: 'fixed', top, left: targetRect.left + elemOffset.left, maxHeight: `calc(100vh - ${top}px)`, width }); this.setPlaceholderStyle({ width, height: elemSize.height }); } else if (scrollTop <= elemOffset.top + elemSize.height + ((/** @type {?} */ (this._offsetBottom))) - targetInnerHeight && offsetMode.bottom) { /** @type {?} */ const targetBottomOffet = targetNode === window ? 0 : window.innerHeight - targetRect.bottom; /** @type {?} */ const width = elemOffset.width; this.setAffixStyle(e, { position: 'fixed', bottom: targetBottomOffet + ((/** @type {?} */ (this._offsetBottom))), left: targetRect.left + elemOffset.left, width }); this.setPlaceholderStyle({ width, height: elemOffset.height }); } else { if (e.type === 'resize' && this.affixStyle && this.affixStyle.position === 'fixed' && this.placeholderNode.offsetWidth) { this.setAffixStyle(e, Object.assign({}, this.affixStyle, { width: this.placeholderNode.offsetWidth })); } else { this.setAffixStyle(e); } this.setPlaceholderStyle(); } if (e.type === 'resize') { this.syncPlaceholderStyle(e); } } } NzAffixComponent.decorators = [ { type: Component, args: [{ selector: 'nz-affix', template: "<div #fixedEl>\n <ng-content></ng-content>\n</div>", changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: [` nz-affix { display: block; } `] }] } ]; /** @nocollapse */ NzAffixComponent.ctorParameters = () => [ { type: ElementRef }, { type: NzScrollService }, { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] } ]; NzAffixComponent.propDecorators = { nzTarget: [{ type: Input }], nzOffsetTop: [{ type: Input }], nzOffsetBottom: [{ type: Input }], nzChange: [{ type: Output }], fixedEl: [{ type: ViewChild, args: ['fixedEl',] }] }; tslib_1.__decorate([ throttleByAnimationFrameDecorator(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Event]), tslib_1.__metadata("design:returntype", void 0) ], NzAffixComponent.prototype, "updatePosition", null); if (false) { /** @type {?} */ NzAffixComponent.prototype.nzChange; /** * @type {?} * @private */ NzAffixComponent.prototype.timeout; /** * @type {?} * @private */ NzAffixComponent.prototype.events; /** * @type {?} * @private */ NzAffixComponent.prototype.fixedEl; /** * @type {?} * @private */ NzAffixComponent.prototype.placeholderNode; /** * @type {?} * @private */ NzAffixComponent.prototype.affixStyle; /** * @type {?} * @private */ NzAffixComponent.prototype.placeholderStyle; /** * @type {?} * @private */ NzAffixComponent.prototype._target; /** * @type {?} * @private */ NzAffixComponent.prototype._offsetTop; /** * @type {?} * @private */ NzAffixComponent.prototype._offsetBottom; /** * @type {?} * @private */ NzAffixComponent.prototype.scrollSrv; /** * @type {?} * @private */ NzAffixComponent.prototype.doc; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotYWZmaXguY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctem9ycm8tYW50ZC15ai8iLCJzb3VyY2VzIjpbImFmZml4L256LWFmZml4LmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMzQyxPQUFPLEVBQ0wsdUJBQXVCLEVBQ3ZCLFNBQVMsRUFDVCxVQUFVLEVBQ1YsWUFBWSxFQUNaLE1BQU0sRUFDTixLQUFLLEVBR0wsTUFBTSxFQUNOLFNBQVMsRUFDVCxpQkFBaUIsRUFDbEIsTUFBTSxlQUFlLENBQUM7QUFFdkIsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBRW5FLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNsRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDaEQsT0FBTyxFQUFFLGlDQUFpQyxFQUFFLE1BQU0sdUNBQXVDLENBQUM7QUFlMUYsTUFBTSxPQUFPLGdCQUFnQjs7Ozs7OztJQThDM0IsWUFBWSxHQUFlLEVBQVUsU0F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