From d0cc3e47465f37e3cec8ca9a87da1cb76e3869f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=A7=E8=A1=A1?= Date: Tue, 5 Dec 2017 11:31:32 +0800 Subject: [PATCH] feat(module:select): support nzScrollToBottom event close #676 --- src/components/select/nz-select.component.ts | 20 ++++++++++++++++++- .../nz-demo-select/nz-demo-select.html | 6 ++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/components/select/nz-select.component.ts b/src/components/select/nz-select.component.ts index 813237eb98..206b725d9e 100644 --- a/src/components/select/nz-select.component.ts +++ b/src/components/select/nz-select.component.ts @@ -129,7 +129,7 @@ import { NzLocaleService } from '../locale/index';
-
    +
    • = new EventEmitter(); @Output() nzOpenChange: EventEmitter = new EventEmitter(); + @Output() nzScrollToBottom: EventEmitter = new EventEmitter(); @Input() nzFilter = true; @Input() nzMaxMultiple = Infinity; @@ -319,6 +320,11 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent this._isOpen = value; this.nzOpenChange.emit(this._isOpen); this.setClassMap(); + if (this._isOpen) { + setTimeout(() => { + this.checkDropDownScroll(); + }); + } } /** new nz-option insert or new tags insert */ @@ -722,6 +728,18 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent this.nzDisabled = isDisabled; } + dropDownScroll(ul) { + if (ul && (ul.scrollHeight - ul.scrollTop === ul.clientHeight)) { + this.nzScrollToBottom.emit(true); + } + } + + checkDropDownScroll() { + if (this.dropdownUl && (this.dropdownUl.nativeElement.scrollHeight === this.dropdownUl.nativeElement.clientHeight)) { + this.nzScrollToBottom.emit(true); + } + } + constructor(private _elementRef: ElementRef, private _renderer: Renderer2, private _locale: NzLocaleService) { this._el = this._elementRef.nativeElement; } diff --git a/src/showcase/nz-demo-select/nz-demo-select.html b/src/showcase/nz-demo-select/nz-demo-select.html index 9e195396b4..369d4bcb08 100644 --- a/src/showcase/nz-demo-select/nz-demo-select.html +++ b/src/showcase/nz-demo-select/nz-demo-select.html @@ -134,6 +134,12 @@

      nz-select attribute - + + nzScrollToBottom + 下拉菜单滚动到底部回调,可用于作为动态加载的触发条件 + - + - + nzPlaceHolder 选择框默认文字