From 3be639a00b2338231d1b6f645e2a62014a255a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=89=B2?= Date: Sat, 29 Dec 2018 19:33:39 +0800 Subject: [PATCH] fix(module:theme): fix not found window value (#355) - remove duplicate icon --- packages/theme/src/services/scroll/scroll.service.ts | 2 +- packages/theme/src/theme.module.ts | 9 ++------- packages/theme/src/win_tokens.ts | 9 ++++++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/theme/src/services/scroll/scroll.service.ts b/packages/theme/src/services/scroll/scroll.service.ts index 32c6c0d72..06ddb8d85 100644 --- a/packages/theme/src/services/scroll/scroll.service.ts +++ b/packages/theme/src/services/scroll/scroll.service.ts @@ -12,7 +12,7 @@ export class ScrollService { * @param element 指定元素,默认 `window` */ getScrollPosition(element?: Element): [ number, number ] { - if (element) { + if (element && element !== this.win) { return [ element.scrollLeft, element.scrollTop ]; } else { return [ this.win.pageXOffset, this.win.pageYOffset ]; diff --git a/packages/theme/src/theme.module.ts b/packages/theme/src/theme.module.ts index 4a54cf96c..a5f30ba08 100644 --- a/packages/theme/src/theme.module.ts +++ b/packages/theme/src/theme.module.ts @@ -3,8 +3,6 @@ import { CommonModule } from '@angular/common'; import { ModuleWithProviders, NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { WINDOW } from './win_tokens'; - import { DelonLocaleModule } from './locale/locale.module'; // #region import @@ -30,21 +28,19 @@ const PIPES = [DatePipe, CNCurrencyPipe, KeysPipe, YNPipe, I18nPipe, HTMLPipe, U // #region all delon used icons +// - zorro: https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/components/icon/nz-icon.service.ts#L6 + import { BellOutline, - CaretDownOutline, CaretUpOutline, DeleteOutline, - FilterFill, InboxOutline, PlusOutline, } from '@ant-design/icons-angular/icons'; import { NzIconService } from 'ng-zorro-antd'; const ICONS = [ BellOutline, - FilterFill, CaretUpOutline, - CaretDownOutline, DeleteOutline, PlusOutline, InboxOutline, @@ -66,7 +62,6 @@ export class AlainThemeModule { return { ngModule: AlainThemeModule, providers: [ - { provide: WINDOW, useValue: window }, ...HELPERS, ], }; diff --git a/packages/theme/src/win_tokens.ts b/packages/theme/src/win_tokens.ts index 276020b1b..8fd7e509d 100644 --- a/packages/theme/src/win_tokens.ts +++ b/packages/theme/src/win_tokens.ts @@ -1,3 +1,10 @@ import { InjectionToken } from '@angular/core'; -export const WINDOW = new InjectionToken('Window'); +function WINDOW_FACTORY(): any { + return window; +} + +export const WINDOW = new InjectionToken('Window', { + providedIn: 'root', + factory: WINDOW_FACTORY, +});