Skip to content

Commit

Permalink
fix(ScrollCollapse): minimise state not set correctly on page load (#31)
Browse files Browse the repository at this point in the history
Fixed a bug when using OnPush change detection where minimise state was not being set correctly on page load and scroll position is not at the top of the page

Fix #21
  • Loading branch information
edoparearyee authored Oct 10, 2018
1 parent 3661e76 commit 2db3d9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component } from '@angular/core';
import { Direction } from '..';
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { Direction } from './scroll-collapse/shared/direction.enum';

@Component({
selector: 'sn-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent {
scrollDirectionHandler(event: Direction) {
Expand Down
1 change: 1 addition & 0 deletions src/app/scroll-collapse/scroll-collapse.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export class ScrollCollapseDirective implements AfterViewInit, OnDestroy {
this.calculateScrollDirection([previousEvent, currentEvent]);
this.calculateMinimiseMode(currentEvent);
this.calculateAffixMode(currentEvent);
this.cdRef.detectChanges();
}
/**
* Remove minimise, affix and scrolling states and recalulate
Expand Down

0 comments on commit 2db3d9f

Please sign in to comment.