From 0b7512dfb720804d67a91cd731c94667d306035c Mon Sep 17 00:00:00 2001 From: cipchk Date: Mon, 4 Dec 2017 18:50:29 +0800 Subject: [PATCH] fix(module:affix): fix position offset when has deferred render componets. --- src/components/affix/nz-affix.component.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/affix/nz-affix.component.ts b/src/components/affix/nz-affix.component.ts index d613191222f..538344de88e 100644 --- a/src/components/affix/nz-affix.component.ts +++ b/src/components/affix/nz-affix.component.ts @@ -7,7 +7,8 @@ import { Output, OnDestroy, ViewChild, - ElementRef + ElementRef, + AfterViewInit } from '@angular/core'; import { fromEvent } from 'rxjs/observable/fromEvent'; import { Subscription } from 'rxjs/Subscription'; @@ -28,7 +29,7 @@ import { NzScrollService } from '../core/scroll/nz-scroll.service'; './style/patch.less' ] }) -export class NzAffixComponent implements OnInit, OnDestroy { +export class NzAffixComponent implements OnInit, OnDestroy, AfterViewInit { private didScroll = false; private scrollTime: any = null; @@ -62,6 +63,11 @@ export class NzAffixComponent implements OnInit, OnDestroy { } } + ngAfterViewInit(): void { + this.orgOffset = null; + this.fixed = false; + } + private getTarget(): Element | Window { return this.target || window; }