From 64fb0cde34b8cf6df402397c5c42739af36102a7 Mon Sep 17 00:00:00 2001 From: NikolayAlipiev Date: Tue, 4 Dec 2018 14:52:55 +0200 Subject: [PATCH] fix(igx-combo): disable checkbox animations on scroll #3243 --- .../src/lib/combo/combo-dropdown.component.ts | 23 +++++++++++++++++-- .../src/lib/combo/combo-item.component.ts | 1 + .../src/lib/combo/combo.component.html | 2 +- .../src/lib/drop-down/drop-down.base.ts | 5 ++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/projects/igniteui-angular/src/lib/combo/combo-dropdown.component.ts b/projects/igniteui-angular/src/lib/combo/combo-dropdown.component.ts index 2dc6bda8506..36382272410 100644 --- a/projects/igniteui-angular/src/lib/combo/combo-dropdown.component.ts +++ b/projects/igniteui-angular/src/lib/combo/combo-dropdown.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectorRef, Component, ContentChild, - ElementRef, forwardRef, Inject, QueryList, EventEmitter, OnDestroy + ElementRef, forwardRef, Inject, QueryList, EventEmitter, OnDestroy, AfterViewInit } from '@angular/core'; import { takeUntil, take } from 'rxjs/operators'; import { IgxComboItemComponent } from './combo-item.component'; @@ -18,7 +18,7 @@ import { Navigate } from '../drop-down/drop-down.common'; templateUrl: '../drop-down/drop-down.component.html', providers: [{ provide: IgxDropDownBase, useExisting: IgxComboDropDownComponent }] }) -export class IgxComboDropDownComponent extends IgxDropDownBase implements OnDestroy { +export class IgxComboDropDownComponent extends IgxDropDownBase implements AfterViewInit, OnDestroy { private _children: QueryList; private _scrollPosition = 0; private destroy$ = new Subject(); @@ -30,6 +30,11 @@ export class IgxComboDropDownComponent extends IgxDropDownBase implements OnDest super(elementRef, cdr, selection); } + /** + * @hidden + */ + private _vScrollListener = null; + /** * @hidden */ @@ -331,6 +336,14 @@ export class IgxComboDropDownComponent extends IgxDropDownBase implements OnDest } protected scrollToHiddenItem(newItem: any): void {} + + /** + * @hidden + */ + protected verticalScrollHandler(event) { + this.disableTransitions = true; + } + /** * @hidden */ @@ -377,10 +390,16 @@ export class IgxComboDropDownComponent extends IgxDropDownBase implements OnDest this.verticalScrollContainer.getVerticalScroll().scrollTop = this._scrollPosition; } + public ngAfterViewInit() { + this._vScrollListener = this.verticalScrollHandler.bind(this); + this.verticalScrollContainer.getVerticalScroll().addEventListener('scroll', this._vScrollListener); + } + /** *@hidden */ public ngOnDestroy(): void { + this.verticalScrollContainer.getVerticalScroll().removeEventListener('scroll', this._vScrollListener); this.destroy$.next(true); this.destroy$.complete(); } diff --git a/projects/igniteui-angular/src/lib/combo/combo-item.component.ts b/projects/igniteui-angular/src/lib/combo/combo-item.component.ts index c6d0b574ac7..f1f29759527 100644 --- a/projects/igniteui-angular/src/lib/combo/combo-item.component.ts +++ b/projects/igniteui-angular/src/lib/combo/combo-item.component.ts @@ -54,6 +54,7 @@ export class IgxComboItemComponent extends IgxDropDownItemBase { */ @HostListener('click', ['$event']) clicked(event) { + this.dropDown.disableTransitions = false; if (this.disabled || this.isHeader) { const focusedItem = this.dropDown.focusedItem; if (focusedItem) { diff --git a/projects/igniteui-angular/src/lib/combo/combo.component.html b/projects/igniteui-angular/src/lib/combo/combo.component.html index e2fc4d7a9fb..4afc9c33fef 100644 --- a/projects/igniteui-angular/src/lib/combo/combo.component.html +++ b/projects/igniteui-angular/src/lib/combo/combo.component.html @@ -43,7 +43,7 @@ (onChunkPreload)="dataLoading($event)" #virtualScrollContainer> - + diff --git a/projects/igniteui-angular/src/lib/drop-down/drop-down.base.ts b/projects/igniteui-angular/src/lib/drop-down/drop-down.base.ts index cefdd64da0a..fd88d8c5395 100644 --- a/projects/igniteui-angular/src/lib/drop-down/drop-down.base.ts +++ b/projects/igniteui-angular/src/lib/drop-down/drop-down.base.ts @@ -271,6 +271,11 @@ export abstract class IgxDropDownBase implements OnInit, IToggleView { return this.elementRef.nativeElement; } + /** + * @hidden + */ + public disableTransitions = false; + /** * Get dropdown's html element of it scroll container */