ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
210 lines • 15.7 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import { DOCUMENT } from '@angular/common';
import { Inject, Injectable, Optional, SkipSelf } from '@angular/core';
import { reqAnimFrame } from '../polyfill/request-animation';
/**
* @param {?} t
* @param {?} b
* @param {?} c
* @param {?} d
* @return {?}
*/
function easeInOutCubic(t, b, c, d) {
/** @type {?} */
var cc = c - b;
/** @type {?} */
var tt = t / (d / 2);
if (tt < 1) {
return (cc / 2) * tt * tt * tt + b;
}
else {
return (cc / 2) * ((tt -= 2) * tt * tt + 2) + b;
}
}
var NzScrollService = /** @class */ (function () {
/* tslint:disable-next-line:no-any */
function NzScrollService(doc) {
this.doc = doc;
}
/** 设置 `el` 滚动条位置 */
/**
* 设置 `el` 滚动条位置
* @param {?} el
* @param {?=} topValue
* @return {?}
*/
NzScrollService.prototype.setScrollTop = /**
* 设置 `el` 滚动条位置
* @param {?} el
* @param {?=} topValue
* @return {?}
*/
function (el, topValue) {
if (topValue === void 0) { topValue = 0; }
if (el === window) {
this.doc.body.scrollTop = topValue;
(/** @type {?} */ (this.doc.documentElement)).scrollTop = topValue;
}
else {
((/** @type {?} */ (el))).scrollTop = topValue;
}
};
/** 获取 `el` 相对于视窗距离 */
/**
* 获取 `el` 相对于视窗距离
* @param {?} el
* @return {?}
*/
NzScrollService.prototype.getOffset = /**
* 获取 `el` 相对于视窗距离
* @param {?} el
* @return {?}
*/
function (el) {
/** @type {?} */
var ret = {
top: 0,
left: 0
};
if (!el || !el.getClientRects().length) {
return ret;
}
/** @type {?} */
var rect = el.getBoundingClientRect();
if (rect.width || rect.height) {
/** @type {?} */
var doc = (/** @type {?} */ (el.ownerDocument)).documentElement;
ret.top = rect.top - (/** @type {?} */ (doc)).clientTop;
ret.left = rect.left - (/** @type {?} */ (doc)).clientLeft;
}
else {
ret.top = rect.top;
ret.left = rect.left;
}
return ret;
};
/** 获取 `el` 滚动条位置 */
// TODO: remove '| Window' as the fallback already happens here
/**
* 获取 `el` 滚动条位置
* @param {?=} el
* @param {?=} top
* @return {?}
*/
// TODO: remove '| Window' as the fallback already happens here
NzScrollService.prototype.getScroll = /**
* 获取 `el` 滚动条位置
* @param {?=} el
* @param {?=} top
* @return {?}
*/
// TODO: remove '| Window' as the fallback already happens here
function (el, top) {
if (top === void 0) { top = true; }
/** @type {?} */
var target = el ? el : window;
/** @type {?} */
var prop = top ? 'pageYOffset' : 'pageXOffset';
/** @type {?} */
var method = top ? 'scrollTop' : 'scrollLeft';
/** @type {?} */
var isWindow = target === window;
// @ts-ignore
/** @type {?} */
var ret = isWindow ? target[prop] : target[method];
if (isWindow && typeof ret !== 'number') {
ret = (/** @type {?} */ (this.doc.documentElement))[method];
}
return ret;
};
/**
* 使用动画形式将 `el` 滚动至某位置
*
* @param containerEl 容器,默认 `window`
* @param targetTopValue 滚动至目标 `top` 值,默认:0,相当于顶部
* @param easing 动作算法,默认:`easeInOutCubic`
* @param callback 动画结束后回调
*/
/**
* 使用动画形式将 `el` 滚动至某位置
*
* @param {?} containerEl 容器,默认 `window`
* @param {?=} targetTopValue 滚动至目标 `top` 值,默认:0,相当于顶部
* @param {?=} easing 动作算法,默认:`easeInOutCubic`
* @param {?=} callback 动画结束后回调
* @return {?}
*/
NzScrollService.prototype.scrollTo = /**
* 使用动画形式将 `el` 滚动至某位置
*
* @param {?} containerEl 容器,默认 `window`
* @param {?=} targetTopValue 滚动至目标 `top` 值,默认:0,相当于顶部
* @param {?=} easing 动作算法,默认:`easeInOutCubic`
* @param {?=} callback 动画结束后回调
* @return {?}
*/
function (containerEl, targetTopValue, easing, callback) {
var _this = this;
if (targetTopValue === void 0) { targetTopValue = 0; }
/** @type {?} */
var target = containerEl ? containerEl : window;
/** @type {?} */
var scrollTop = this.getScroll(target);
/** @type {?} */
var startTime = Date.now();
/** @type {?} */
var frameFunc = (/**
* @return {?}
*/
function () {
/** @type {?} */
var timestamp = Date.now();
/** @type {?} */
var time = timestamp - startTime;
_this.setScrollTop(target, (easing || easeInOutCubic)(time, scrollTop, targetTopValue, 450));
if (time < 450) {
reqAnimFrame(frameFunc);
}
else {
if (callback) {
callback();
}
}
});
reqAnimFrame(frameFunc);
};
NzScrollService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
NzScrollService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
]; };
return NzScrollService;
}());
export { NzScrollService };
if (false) {
/**
* @type {?}
* @private
*/
NzScrollService.prototype.doc;
}
/**
* @param {?} doc
* @param {?} scrollService
* @return {?}
*/
export function SCROLL_SERVICE_PROVIDER_FACTORY(doc, scrollService) {
return scrollService || new NzScrollService(doc);
}
/** @type {?} */
export var SCROLL_SERVICE_PROVIDER = {
provide: NzScrollService,
useFactory: SCROLL_SERVICE_PROVIDER_FACTORY,
deps: [DOCUMENT, [new Optional(), new SkipSelf(), NzScrollService]]
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotc2Nyb2xsLnNlcnZpY2UuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZy16b3Jyby1hbnRkLXlqLyIsInNvdXJjZXMiOlsiY29yZS9zY3JvbGwvbnotc2Nyb2xsLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMzQyxPQUFPLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxRQUFRLEVBQVksUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRWpGLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQzs7Ozs7Ozs7QUFJN0QsU0FBUyxjQUFjLENBQUMsQ0FBUyxFQUFFLENBQVMsRUFBRSx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