55 OnInit ,
66 ViewChild ,
77 ElementRef ,
8- OnDestroy ,
98} from '@angular/core' ;
109import { TestBed , ComponentFixture , fakeAsync , tick , waitForAsync } from '@angular/core/testing' ;
1110import { IgxScrollInertiaDirective } from './scroll_inertia.directive' ;
@@ -348,13 +347,13 @@ export class IgxTestScrollInertiaDirective extends IgxScrollInertiaDirective {
348347 <div #container style='width:calc(100% - 50px); height: 500px; float: left;'>
349348 <ng-template igxTestScrollInertia #scrInertiaContainer></ng-template>
350349 </div>
351- <div #scrBar [style.height]='height' style='overflow: auto; width: 50px; float:right;'>
350+ <div #scrBar [style.height]='height' style='overflow: auto; width: 50px; float:right;' (scroll)="this.onScroll($event)" >
352351 <div [style.height]='innerHeight' [style.width]='innerWidth'></div>
353352 </div>
354353 ` ,
355354 imports : [ IgxTestScrollInertiaDirective ]
356355} )
357- export class ScrollInertiaComponent implements OnInit , OnDestroy {
356+ export class ScrollInertiaComponent implements OnInit {
358357 @ViewChild ( 'container' , { static : true } ) public container : ElementRef ;
359358 @ViewChild ( 'scrBar' , { static : true } ) public scrollContainer : ElementRef ;
360359 @ViewChild ( 'scrInertiaContainer' , { read : IgxTestScrollInertiaDirective , static : true } )
@@ -370,9 +369,6 @@ export class ScrollInertiaComponent implements OnInit, OnDestroy {
370369
371370 public ngOnInit ( ) {
372371 this . scrInertiaDir . IgxScrollInertiaScrollContainer = this . scrollContainer . nativeElement ;
373-
374- this . onScroll = this . onScroll . bind ( this ) ;
375- this . scrollContainer . nativeElement . addEventListener ( 'scroll' , this . onScroll ) ;
376372 }
377373
378374 public onScroll ( evt ) {
@@ -386,8 +382,4 @@ export class ScrollInertiaComponent implements OnInit, OnDestroy {
386382 this . scrTopStepArray . push ( calcScrollStep ) ;
387383 this . scrLeftStepArray . push ( calcScrollLeftStep ) ;
388384 }
389-
390- public ngOnDestroy ( ) : void {
391- this . scrollContainer . nativeElement . removeEventListener ( 'scroll' , this . onScroll ) ;
392- }
393385}
0 commit comments