UNPKG

ng-zorro-antd-yj

Version:

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

251 lines 17.6 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { Platform } from '@angular/cdk/platform'; var NzWaveRenderer = /** @class */ (function () { function NzWaveRenderer(triggerElement, ngZone, insertExtraNode) { var _this = this; this.triggerElement = triggerElement; this.ngZone = ngZone; this.insertExtraNode = insertExtraNode; this.waveTransitionDuration = 400; this.lastTime = 0; this.onClick = (/** * @param {?} event * @return {?} */ function (event) { if (!_this.triggerElement || !_this.triggerElement.getAttribute || _this.triggerElement.getAttribute('disabled') || ((/** @type {?} */ (event.target))).tagName === 'INPUT' || _this.triggerElement.className.indexOf('disabled') >= 0) { return; } _this.fadeOutWave(); }); /** @type {?} */ var platform = new Platform(); if (platform.isBrowser) { this.bindTriggerEvent(); } } Object.defineProperty(NzWaveRenderer.prototype, "waveAttributeName", { get: /** * @return {?} */ function () { return this.insertExtraNode ? 'ant-click-animating' : 'ant-click-animating-without-extra-node'; }, enumerable: true, configurable: true }); /** * @return {?} */ NzWaveRenderer.prototype.bindTriggerEvent = /** * @return {?} */ function () { var _this = this; this.ngZone.runOutsideAngular((/** * @return {?} */ function () { if (_this.triggerElement) { _this.triggerElement.addEventListener('click', _this.onClick, true); } })); }; /** * @return {?} */ NzWaveRenderer.prototype.removeTriggerEvent = /** * @return {?} */ function () { if (this.triggerElement) { this.triggerElement.removeEventListener('click', this.onClick, true); } }; /** * @return {?} */ NzWaveRenderer.prototype.removeStyleAndExtraNode = /** * @return {?} */ function () { if (this.styleForPseudo && document.body.contains(this.styleForPseudo)) { document.body.removeChild(this.styleForPseudo); this.styleForPseudo = null; } if (this.insertExtraNode && this.triggerElement.contains(this.extraNode)) { this.triggerElement.removeChild((/** @type {?} */ (this.extraNode))); } }; /** * @return {?} */ NzWaveRenderer.prototype.destroy = /** * @return {?} */ function () { this.removeTriggerEvent(); this.removeStyleAndExtraNode(); }; /** * @private * @return {?} */ NzWaveRenderer.prototype.fadeOutWave = /** * @private * @return {?} */ function () { var _this = this; /** @type {?} */ var node = this.triggerElement; /** @type {?} */ var waveColor = this.getWaveColor(node); node.setAttribute(this.waveAttributeName, 'true'); if (Date.now() < this.lastTime + this.waveTransitionDuration) { return; } if (this.isValidColor(waveColor)) { if (!this.styleForPseudo) { this.styleForPseudo = document.createElement('style'); } this.styleForPseudo.innerHTML = "[ant-click-animating-without-extra-node]:after { border-color: " + waveColor + "; }"; document.body.appendChild(this.styleForPseudo); } if (this.insertExtraNode) { if (!this.extraNode) { this.extraNode = document.createElement('div'); } this.extraNode.className = 'ant-click-animating-node'; node.appendChild(this.extraNode); } this.lastTime = Date.now(); this.runTimeoutOutsideZone((/** * @return {?} */ function () { node.removeAttribute(_this.waveAttributeName); _this.removeStyleAndExtraNode(); }), this.waveTransitionDuration); }; /** * @private * @param {?} color * @return {?} */ NzWaveRenderer.prototype.isValidColor = /** * @private * @param {?} color * @return {?} */ function (color) { return (!!color && color !== '#ffffff' && color !== 'rgb(255, 255, 255)' && this.isNotGrey(color) && !/rgba\(\d*, \d*, \d*, 0\)/.test(color) && color !== 'transparent'); }; /** * @private * @param {?} color * @return {?} */ NzWaveRenderer.prototype.isNotGrey = /** * @private * @param {?} color * @return {?} */ function (color) { /** @type {?} */ var match = color.match(/rgba?\((\d*), (\d*), (\d*)(, [\.\d]*)?\)/); if (match && match[1] && match[2] && match[3]) { return !(match[1] === match[2] && match[2] === match[3]); } return true; }; /** * @private * @param {?} node * @return {?} */ NzWaveRenderer.prototype.getWaveColor = /** * @private * @param {?} node * @return {?} */ function (node) { /** @type {?} */ var nodeStyle = getComputedStyle(node); return (nodeStyle.getPropertyValue('border-top-color') || // Firefox Compatible nodeStyle.getPropertyValue('border-color') || nodeStyle.getPropertyValue('background-color')); }; /** * @private * @param {?} fn * @param {?} delay * @return {?} */ NzWaveRenderer.prototype.runTimeoutOutsideZone = /** * @private * @param {?} fn * @param {?} delay * @return {?} */ function (fn, delay) { this.ngZone.runOutsideAngular((/** * @return {?} */ function () { return setTimeout(fn, delay); })); }; return NzWaveRenderer; }()); export { NzWaveRenderer }; if (false) { /** * @type {?} * @private */ NzWaveRenderer.prototype.waveTransitionDuration; /** * @type {?} * @private */ NzWaveRenderer.prototype.styleForPseudo; /** * @type {?} * @private */ NzWaveRenderer.prototype.extraNode; /** * @type {?} * @private */ NzWaveRenderer.prototype.lastTime; /** @type {?} */ NzWaveRenderer.prototype.onClick; /** * @type {?} * @private */ NzWaveRenderer.prototype.triggerElement; /** * @type {?} * @private */ NzWaveRenderer.prototype.ngZone; /** * @type {?} * @private */ NzWaveRenderer.prototype.insertExtraNode; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotd2F2ZS1yZW5kZXJlci5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nLXpvcnJvLWFudGQteWovIiwic291cmNlcyI6WyJjb3JlL3dhdmUvbnotd2F2ZS1yZW5kZXJlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBR2pEO0lBVUUsd0JBQW9CLGNBQTJCLEVBQVUsTUFBYyxFQUFVLGVBQXdCO1FBQXpHLGlCQUtDO1FBTG1CLG1CQUFjLEdBQWQsY0FBYyxDQUFhO1FBQVUsV0FBTSxHQUFOLE1BQU0sQ0FBUTtRQUFVLG9CQUFlLEdBQWYsZUFBZSxDQUFTO1FBVGpHLDJCQUFzQixHQUFHLEdBQUcsQ0FBQztRQUc3QixhQUFRLEdBQUcsQ0FBQyxDQUFDO1FBYXJCLFlBQU87Ozs7UUFBRyxVQUFDLEtBQWlCO1lBQzFCLElBQ0UsQ0FBQyxLQUFJLENBQUMsY0FBYztnQkFDcEIsQ0FBQyxLQUFJLENBQUMsY0FBYyxDQUFDLFlBQVk7Z0JBQ2pDLEt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