diff --git a/CHANGELOG.md b/CHANGELOG.md index 8077bc5b..cc43964d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v 0.5.1 (2017/04/25) +* [FIX] - fixes #156 - running scroll logics outside of angular's zone + ## v 0.5.0 (2017/04/24) * [MAINTAINANCE] - code refactor - removing factories to rely more pure functional methods in PositionResolver, AxisResolver diff --git a/package.json b/package.json index 050c076b..e2a78213 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-infinite-scroll", - "version": "0.5.0", + "version": "0.5.1", "description": "An infinite scroll directive for Angular compatible with AoT compilation and Tree shaking", "main": "./bundles/ngx-infinite-scroll.umd.js", "module": "./modules/ngx-infinite-scroll.es5.js", diff --git a/src/modules/infinite-scroll.directive.ts b/src/modules/infinite-scroll.directive.ts index 10bbf49a..9c674eba 100644 --- a/src/modules/infinite-scroll.directive.ts +++ b/src/modules/infinite-scroll.directive.ts @@ -40,19 +40,21 @@ export class InfiniteScrollDirective implements OnDestroy, OnInit { ngOnInit() { if (typeof window !== 'undefined') { - const containerElement = this.resolveContainerElement(); - const resolver = this.positionResolver.create({ - axis: new AxisResolver(!this.horizontal), - windowElement: containerElement, + this.zone.runOutsideAngular(() => { + const containerElement = this.resolveContainerElement(); + const resolver = this.positionResolver.create({ + axis: new AxisResolver(!this.horizontal), + windowElement: containerElement, + }); + const options: IScrollRegisterConfig = { + container: resolver.container, + filterBefore: () => !this.infiniteScrollDisabled, + mergeMap: () => this.positionResolver.calculatePoints(this.element, resolver), + scrollHandler: (container: IPositionStats) => this.handleOnScroll(container), + throttleDuration: this.infiniteScrollThrottle + }; + this.disposeScroller = this.scrollRegister.attachEvent(options); }); - const options: IScrollRegisterConfig = { - container: resolver.container, - filterBefore: () => !this.infiniteScrollDisabled, - mergeMap: () => this.positionResolver.calculatePoints(this.element, resolver), - scrollHandler: (container: IPositionStats) => this.handleOnScroll(container), - throttleDuration: this.infiniteScrollThrottle - }; - this.disposeScroller = this.scrollRegister.attachEvent(options); } }