diff --git a/components/affix/affix.spec.ts b/components/affix/affix.spec.ts index bcda2bcc231..e723e098f95 100644 --- a/components/affix/affix.spec.ts +++ b/components/affix/affix.spec.ts @@ -1,4 +1,4 @@ -import { BidiModule, Dir, Directionality } from '@angular/cdk/bidi'; +import { BidiModule, Dir, Direction, Directionality } from '@angular/cdk/bidi'; import { Platform } from '@angular/cdk/platform'; import { DOCUMENT } from '@angular/common'; import { Component, DebugElement, ElementRef, Renderer2, ViewChild } from '@angular/core'; @@ -358,7 +358,7 @@ describe('affix', () => { discardPeriodicTasks(); })); - it(`emit false when is unaffixed`, fakeAsync(() => { + it(`emit false when isn't affixed`, fakeAsync(() => { setupInitialState(); emitScroll(window, defaultOffsetTop + startOffset + 1); emitScroll(window, defaultOffsetTop + startOffset - 1); @@ -524,8 +524,7 @@ describe('affix RTL', () => { dl = fixture.debugElement; })); it('should className correct on dir change', fakeAsync(() => { - const value = 10; - context.newOffsetBottom = value; + context.newOffsetBottom = 10; context.fakeTarget = window; fixture.detectChanges(); const el = dl.query(By.css('nz-affix')).nativeElement as HTMLElement; @@ -555,7 +554,7 @@ describe('affix RTL', () => { }) class TestAffixComponent { @ViewChild(NzAffixComponent, { static: true }) nzAffixComponent!: NzAffixComponent; - fakeTarget: string | Element | Window | null = null; + fakeTarget?: string | Element | Window; newOffset!: number; newOffsetBottom!: number; } @@ -572,10 +571,10 @@ class TestAffixComponent { }) export class TestAffixRtlComponent { @ViewChild(Dir) dir!: Dir; - direction = 'rtl'; + direction: Direction = 'rtl'; @ViewChild(NzAffixComponent, { static: true }) nzAffixComponent!: NzAffixComponent; - fakeTarget: string | Element | Window | null = null; + fakeTarget?: string | Element | Window; newOffset!: number; newOffsetBottom!: number; } diff --git a/components/affix/demo/basic.ts b/components/affix/demo/basic.ts index 1c121310253..edfce8a6860 100644 --- a/components/affix/demo/basic.ts +++ b/components/affix/demo/basic.ts @@ -1,7 +1,12 @@ import { Component } from '@angular/core'; +import { NzAffixModule } from 'ng-zorro-antd/affix'; +import { NzButtonModule } from 'ng-zorro-antd/button'; + @Component({ + standalone: true, selector: 'nz-demo-affix-basic', + imports: [NzAffixModule, NzButtonModule], template: `