Skip to content

Commit

Permalink
fix(module:theme): fix not found window value (#355)
Browse files Browse the repository at this point in the history
- remove duplicate icon
  • Loading branch information
cipchk authored Dec 29, 2018
1 parent 9f99ee3 commit 3be639a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/theme/src/services/scroll/scroll.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down
9 changes: 2 additions & 7 deletions packages/theme/src/theme.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -66,7 +62,6 @@ export class AlainThemeModule {
return {
ngModule: AlainThemeModule,
providers: [
{ provide: WINDOW, useValue: window },
...HELPERS,
],
};
Expand Down
9 changes: 8 additions & 1 deletion packages/theme/src/win_tokens.ts
Original file line number Diff line number Diff line change
@@ -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,
});

0 comments on commit 3be639a

Please sign in to comment.