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

Disable combo checkbox animations on scroll #3304

Merged
merged 7 commits into from
Dec 6, 2018
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<IgxDropDownItemBase>;
private _scrollPosition = 0;
private destroy$ = new Subject<boolean>();
Expand Down Expand Up @@ -331,6 +331,14 @@ export class IgxComboDropDownComponent extends IgxDropDownBase implements OnDest
}

protected scrollToHiddenItem(newItem: any): void {}

/**
* @hidden
*/
protected scrollHandler = () => {
this.disableTransitions = true;
}

/**
* @hidden
*/
Expand Down Expand Up @@ -377,10 +385,15 @@ export class IgxComboDropDownComponent extends IgxDropDownBase implements OnDest
this.verticalScrollContainer.getVerticalScroll().scrollTop = this._scrollPosition;
}

public ngAfterViewInit() {
this.verticalScrollContainer.getVerticalScroll().addEventListener('scroll', this.scrollHandler);
}

/**
*@hidden
*/
public ngOnDestroy(): void {
this.verticalScrollContainer.getVerticalScroll().removeEventListener('scroll', this.scrollHandler);
this.destroy$.next(true);
this.destroy$.complete();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
(onChunkPreload)="dataLoading($event)" #virtualScrollContainer>
<igx-combo-item [value]="item" isHeader={{item.isHeader}} role="option">
<ng-container *ngIf="!item.isHeader">
<igx-checkbox [checked]="isItemSelected(item)" disableRipple="true" disabled="true" class="igx-combo__checkbox"></igx-checkbox>
<igx-checkbox [checked]="isItemSelected(item)" disableRipple="true" [disableTransitions]="dropdown.disableTransitions" disabled="true" class="igx-combo__checkbox"></igx-checkbox>
</ng-container>
<ng-container *ngIf="item.isHeader">
<ng-container *ngTemplateOutlet="headerItemTemplate ? headerItemTemplate : headerItemBase; context: {$implicit: item, data: data, valueKey: valueKey, groupKey: groupKey, displayKey: displayKey}"></ng-container>
Expand Down
6 changes: 6 additions & 0 deletions projects/igniteui-angular/src/lib/drop-down/drop-down.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ export abstract class IgxDropDownBase implements OnInit, IToggleView {
return this.elementRef.nativeElement;
}

/**
* @hidden
* @internal
*/
public disableTransitions = false;

/**
* Get dropdown's html element of it scroll container
*/
Expand Down