Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(module:select): support nzScrollToBottom event #678

Merged
merged 1 commit into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/components/select/nz-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ import { NzLocaleService } from '../locale/index';
<div
[ngClass]="_dropDownClassMap" [@dropDownAnimation]="_dropDownPosition">
<div style="overflow: auto;">
<ul class="ant-select-dropdown-menu ant-select-dropdown-menu-vertical ant-select-dropdown-menu-root" #dropdownUl>
<ul class="ant-select-dropdown-menu ant-select-dropdown-menu-vertical ant-select-dropdown-menu-root" #dropdownUl (scroll)="dropDownScroll(dropdownUl)">
<li
*ngFor="let option of _filterOptions"
[class.ant-select-dropdown-menu-item-disabled]="option.nzDisabled"
Expand Down Expand Up @@ -189,6 +189,7 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent
@ViewChild('dropdownUl') dropdownUl: ElementRef;
@Output() nzSearchChange: EventEmitter<any> = new EventEmitter();
@Output() nzOpenChange: EventEmitter<any> = new EventEmitter();
@Output() nzScrollToBottom: EventEmitter<any> = new EventEmitter();
@Input() nzFilter = true;
@Input() nzMaxMultiple = Infinity;

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions src/showcase/nz-demo-select/nz-demo-select.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ <h3 id="Select props"><span>nz-select</span>
<td>attribute</td>
<td>-</td>
</tr>
<tr>
<td>nzScrollToBottom</td>
<td>下拉菜单滚动到底部回调,可用于作为动态加载的触发条件</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>nzPlaceHolder</td>
<td>选择框默认文字</td>
Expand Down