Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngx-infinite-scroll

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-infinite-scroll - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

135

bundles/ngx-infinite-scroll.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/add/observable/fromEvent'), require('rxjs/add/observable/of'), require('rxjs/add/operator/filter'), require('rxjs/add/operator/mergeMap'), require('rxjs/add/operator/sampleTime'), require('rxjs/Observable')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/add/observable/fromEvent', 'rxjs/add/observable/of', 'rxjs/add/operator/filter', 'rxjs/add/operator/mergeMap', 'rxjs/add/operator/sampleTime', 'rxjs/Observable'], factory) :
(factory((global.ng = global.ng || {}, global.ng.ngxInfiniteScroll = global.ng.ngxInfiniteScroll || {}),global.ng.core,null,null,null,null,null,global.Rx));
}(this, (function (exports,_angular_core,rxjs_add_observable_fromEvent,rxjs_add_observable_of,rxjs_add_operator_filter,rxjs_add_operator_mergeMap,rxjs_add_operator_sampleTime,rxjs_Observable) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/add/observable/fromEvent'), require('rxjs/add/observable/of'), require('rxjs/add/operator/filter'), require('rxjs/add/operator/mergeMap'), require('rxjs/add/operator/map'), require('rxjs/add/operator/do'), require('rxjs/add/operator/sampleTime'), require('rxjs/Observable'), require('rxjs/observable/of')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/add/observable/fromEvent', 'rxjs/add/observable/of', 'rxjs/add/operator/filter', 'rxjs/add/operator/mergeMap', 'rxjs/add/operator/map', 'rxjs/add/operator/do', 'rxjs/add/operator/sampleTime', 'rxjs/Observable', 'rxjs/observable/of'], factory) :
(factory((global.ng = global.ng || {}, global.ng.ngxInfiniteScroll = global.ng.ngxInfiniteScroll || {}),global.ng.core,null,null,null,null,null,null,null,global.Rx,global.rxjs_observable_of));
}(this, (function (exports,_angular_core,rxjs_add_observable_fromEvent,rxjs_add_observable_of,rxjs_add_operator_filter,rxjs_add_operator_mergeMap,rxjs_add_operator_map,rxjs_add_operator_do,rxjs_add_operator_sampleTime,rxjs_Observable,rxjs_observable_of) { 'use strict';

@@ -90,23 +90,11 @@ /**

/**
* @param {?} __0
* @param {?} alwaysCallback
* @param {?} shouldFireScrollEvent
* @param {?} isTriggeredCurrentTotal
* @return {?}
*/
function shouldTriggerEvents(_a) {
var alwaysCallback = _a.alwaysCallback, shouldFireScrollEvent = _a.shouldFireScrollEvent;
return (alwaysCallback || shouldFireScrollEvent);
function shouldTriggerEvents(alwaysCallback, shouldFireScrollEvent, isTriggeredCurrentTotal) {
return (alwaysCallback || shouldFireScrollEvent) && !isTriggeredCurrentTotal;
}
/**
* @param {?} callbacks
* @param {?} isScrollingDown
* @param {?} scrolledUntilNow
* @return {?}
*/
function triggerEvents(callbacks, isScrollingDown, scrolledUntilNow) {
var /** @type {?} */ eventData = {
currentScrollPosition: scrolledUntilNow
};
var /** @type {?} */ callback = isScrollingDown ? callbacks.down : callbacks.up;
callback(eventData);
}
/**
* @param {?} __0

@@ -260,8 +248,7 @@ * @return {?}

* @param {?} container
* @param {?} config
* @param {?} distance
* @param {?} scrollingDown
* @return {?}
*/
function shouldFireScrollEvent(container, config, scrollingDown) {
var /** @type {?} */ distance = config.distance;
function shouldFireScrollEvent(container, distance, scrollingDown) {
var /** @type {?} */ remaining;

@@ -291,9 +278,9 @@ var /** @type {?} */ containerBreakpoint;

* @param {?} container
* @param {?} config
* @param {?} distance
* @return {?}
*/
function getScrollStats(lastScrollPosition, container, config) {
function getScrollStats(lastScrollPosition, container, distance) {
var /** @type {?} */ isScrollingDown = isScrollingDownwards(lastScrollPosition, container);
return {
shouldFireScrollEvent: shouldFireScrollEvent(container, config, isScrollingDown),
shouldFireScrollEvent: shouldFireScrollEvent(container, distance, isScrollingDown),
isScrollingDown: isScrollingDown

@@ -367,7 +354,23 @@ };

container: resolver.container,
mergeMap: function () { return calculatePoints(element, resolver); },
scrollHandler: function (positionStats) { return handleOnScroll(scrollState, positionStats, config); },
throttleDuration: config.throttle
throttle: config.throttle
};
return attachScrollEvent(options);
var /** @type {?} */ distance = {
up: config.upDistance,
down: config.downDistance
};
return attachScrollEvent(options)
.mergeMap(function (ev) { return rxjs_observable_of.of(calculatePoints(element, resolver)); })
.map(function (positionStats) { return toInfiniteScrollParams(scrollState.lastScrollPosition, positionStats, distance); })
.do(function (_a) {
var positionStats = _a.positionStats;
return updateScrollState(scrollState, positionStats.scrolledUntilNow, positionStats.totalToScroll);
})
.filter(function (_a) {
var shouldFireScrollEvent$$1 = _a.shouldFireScrollEvent;
return shouldTriggerEvents(shouldFireScrollEvent$$1, config.alwaysCallback, scrollState.isTriggeredTotal);
})
.do(function () {
updateTriggeredFlag(scrollState, true);
})
.map(toInfiniteScrollAction);
}

@@ -379,29 +382,36 @@ /**

function attachScrollEvent(options) {
return rxjs_Observable.Observable.fromEvent(options.container, 'scroll')
.sampleTime(options.throttleDuration)
.mergeMap(function (ev) { return rxjs_Observable.Observable.of(options.mergeMap(ev)); })
.subscribe(options.scrollHandler);
return rxjs_Observable.Observable
.fromEvent(options.container, 'scroll')
.sampleTime(options.throttle);
}
/**
* @param {?} scrollState
* @param {?} lastScrollPosition
* @param {?} positionStats
* @param {?} config
* @param {?} distance
* @return {?}
*/
function handleOnScroll(scrollState, positionStats, config) {
var /** @type {?} */ distance = {
down: config.downDistance,
up: config.upDistance
function toInfiniteScrollParams(lastScrollPosition, positionStats, distance) {
var _a = getScrollStats(lastScrollPosition, positionStats, distance), isScrollingDown = _a.isScrollingDown, shouldFireScrollEvent$$1 = _a.shouldFireScrollEvent;
return {
isScrollingDown: isScrollingDown,
shouldFireScrollEvent: shouldFireScrollEvent$$1,
positionStats: positionStats
};
var _a = getScrollStats(scrollState.lastScrollPosition, positionStats, { distance: distance }), isScrollingDown = _a.isScrollingDown, shouldFireScrollEvent$$1 = _a.shouldFireScrollEvent;
var /** @type {?} */ scrollConfig = {
alwaysCallback: config.alwaysCallback,
shouldFireScrollEvent: shouldFireScrollEvent$$1
}
var InfiniteScrollActions = {
DOWN: '[NGX_ISE] DOWN',
UP: '[NGX_ISE] UP'
};
/**
* @param {?} response
* @return {?}
*/
function toInfiniteScrollAction(response) {
var isScrollingDown = response.isScrollingDown, currentScrollPosition = response.positionStats.scrolledUntilNow;
return {
type: isScrollingDown ? InfiniteScrollActions.DOWN : InfiniteScrollActions.UP,
payload: {
currentScrollPosition: currentScrollPosition
}
};
updateScrollState(scrollState, positionStats.scrolledUntilNow, positionStats.totalToScroll);
var /** @type {?} */ shouldTrigger = shouldTriggerEvents(scrollConfig);
if (shouldTrigger && !scrollState.isTriggeredTotal) {
updateTriggeredFlag(scrollState, true);
triggerEvents(config.events, isScrollingDown, positionStats.scrolledUntilNow);
}
}

@@ -468,8 +478,2 @@ var InfiniteScrollDirective = (function () {

element: _this.element,
events: {
// tslint:disable-next-line:arrow-parens
down: function (event) { return _this.zone.run(function () { return _this.scrolled.emit(event); }); },
// tslint:disable-next-line:arrow-parens
up: function (event) { return _this.zone.run(function () { return _this.scrolledUp.emit(event); }); }
},
horizontal: _this.horizontal,

@@ -480,3 +484,3 @@ scrollContainer: _this.infiniteScrollContainer,

upDistance: _this.infiniteScrollUpDistance
});
}).subscribe(function (payload) { return _this.zone.run(function () { return _this.handleOnScroll(payload); }); });
});

@@ -486,4 +490,19 @@ }

/**
* @param {?} __0
* @return {?}
*/
InfiniteScrollDirective.prototype.handleOnScroll = function (_a) {
var type = _a.type, payload = _a.payload;
switch (type) {
case InfiniteScrollActions.DOWN:
return this.scrolled.emit(payload);
case InfiniteScrollActions.UP:
return this.scrolledUp.emit(payload);
default:
return;
}
};
/**
* @return {?}
*/
InfiniteScrollDirective.prototype.ngOnDestroy = function () {

@@ -490,0 +509,0 @@ this.destroyScroller();

@@ -1,2 +0,2 @@

!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs/add/observable/fromEvent"),require("rxjs/add/observable/of"),require("rxjs/add/operator/filter"),require("rxjs/add/operator/mergeMap"),require("rxjs/add/operator/sampleTime"),require("rxjs/Observable")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/add/observable/fromEvent","rxjs/add/observable/of","rxjs/add/operator/filter","rxjs/add/operator/mergeMap","rxjs/add/operator/sampleTime","rxjs/Observable"],factory):factory((global.ng=global.ng||{},global.ng.ngxInfiniteScroll=global.ng.ngxInfiniteScroll||{}),global.ng.core,null,null,null,null,null,global.Rx)}(this,function(exports,_angular_core,rxjs_add_observable_fromEvent,rxjs_add_observable_of,rxjs_add_operator_filter,rxjs_add_operator_mergeMap,rxjs_add_operator_sampleTime,rxjs_Observable){"use strict";function resolveContainerElement(selector,scrollWindow,defaultElement,fromRoot){var hasWindow=window&&!!window.document&&window.document.documentElement,container=hasWindow&&scrollWindow?window:defaultElement;if(selector){if(!(container=selector&&hasWindow&&"string"==typeof selector?findElement(selector,defaultElement.nativeElement,fromRoot):selector))throw new Error("ngx-infinite-scroll {resolveContainerElement()}: selector for")}return container}function findElement(selector,customRoot,fromRoot){return(fromRoot?window.document:customRoot).querySelector(selector)}function inputPropChanged(prop){return prop&&!prop.firstChange}function hasWindowDefined(){return"undefined"!=typeof window}function shouldTriggerEvents(_a){var alwaysCallback=_a.alwaysCallback,shouldFireScrollEvent=_a.shouldFireScrollEvent;return alwaysCallback||shouldFireScrollEvent}function triggerEvents(callbacks,isScrollingDown,scrolledUntilNow){var eventData={currentScrollPosition:scrolledUntilNow};(isScrollingDown?callbacks.down:callbacks.up)(eventData)}function createResolver(_a){var windowElement=_a.windowElement;return createResolverWithContainer({axis:_a.axis,isWindow:isElementWindow(windowElement)},windowElement)}function createResolverWithContainer(resolver,windowElement){var container=resolver.isWindow||windowElement&&!windowElement.nativeElement?windowElement:windowElement.nativeElement;return Object.assign({},resolver,{container:container})}function isElementWindow(windowElement){return["Window","global"].some(function(obj){return Object.prototype.toString.call(windowElement).includes(obj)})}function getDocumentElement(isContainerWindow,windowElement){return isContainerWindow?windowElement.document.documentElement:null}function calculatePoints(element,resolver){var height=extractHeightForElement(resolver);return resolver.isWindow?calculatePointsForWindow(height,element,resolver):calculatePointsForElement(height,element,resolver)}function calculatePointsForWindow(height,element,resolver){var axis=resolver.axis,container=resolver.container,isWindow=resolver.isWindow,_a=extractHeightPropKeys(axis),offsetHeightKey=_a.offsetHeightKey,clientHeightKey=_a.clientHeightKey,scrolledUntilNow=height+getElementPageYOffset(getDocumentElement(isWindow,container),axis,isWindow),nativeElementHeight=getElementHeight(element.nativeElement,isWindow,offsetHeightKey,clientHeightKey);return{height:height,scrolledUntilNow:scrolledUntilNow,totalToScroll:getElementOffsetTop(element.nativeElement,axis,isWindow)+nativeElementHeight}}function calculatePointsForElement(height,element,resolver){var axis=resolver.axis,container=resolver.container;return{height:height,scrolledUntilNow:container[axis.scrollTopKey()],totalToScroll:container[axis.scrollHeightKey()]}}function extractHeightPropKeys(axis){return{offsetHeightKey:axis.offsetHeightKey(),clientHeightKey:axis.clientHeightKey()}}function extractHeightForElement(_a){var container=_a.container,isWindow=_a.isWindow,axis=_a.axis,_b=extractHeightPropKeys(axis);return getElementHeight(container,isWindow,_b.offsetHeightKey,_b.clientHeightKey)}function getElementHeight(elem,isWindow,offsetHeightKey,clientHeightKey){return isNaN(elem[offsetHeightKey])?getDocumentElement(isWindow,elem)[clientHeightKey]:elem[offsetHeightKey]}function getElementOffsetTop(elem,axis,isWindow){var topKey=axis.topKey();if(elem.getBoundingClientRect)return elem.getBoundingClientRect()[topKey]+getElementPageYOffset(elem,axis,isWindow)}function getElementPageYOffset(elem,axis,isWindow){var pageYOffset=axis.pageYOffsetKey(),scrollTop=axis.scrollTopKey(),offsetTop=axis.offsetTopKey();return isNaN(window[pageYOffset])?getDocumentElement(isWindow,elem)[scrollTop]:elem.ownerDocument?elem.ownerDocument.defaultView[pageYOffset]:elem[offsetTop]}function shouldFireScrollEvent(container,config,scrollingDown){var remaining,containerBreakpoint,distance=config.distance;return scrollingDown?(remaining=(container.totalToScroll-container.scrolledUntilNow)/container.totalToScroll,containerBreakpoint=distance.down/10):(remaining=container.scrolledUntilNow/container.totalToScroll,containerBreakpoint=distance.up/10),remaining<=containerBreakpoint}function isScrollingDownwards(lastScrollPosition,container){return lastScrollPosition<container.scrolledUntilNow}function getScrollStats(lastScrollPosition,container,config){var isScrollingDown=isScrollingDownwards(lastScrollPosition,container);return{shouldFireScrollEvent:shouldFireScrollEvent(container,config,isScrollingDown),isScrollingDown:isScrollingDown}}function updateScrollPosition(position,scrollState){return scrollState.lastScrollPosition=position}function updateTotalToScroll(totalToScroll,scrollState){scrollState.lastTotalToScroll=scrollState.totalToScroll,scrollState.totalToScroll=totalToScroll}function isSameTotalToScroll(scrollState){return scrollState.totalToScroll===scrollState.lastTotalToScroll}function updateTriggeredFlag(scrollState,triggered){scrollState.isTriggeredTotal=triggered}function updateScrollState(scrollState,scrolledUntilNow,totalToScroll){updateScrollPosition(scrolledUntilNow,scrollState),updateTotalToScroll(totalToScroll,scrollState),isSameTotalToScroll(scrollState)||updateTriggeredFlag(scrollState,!1)}function createScroller(config){var scrollContainer=config.scrollContainer,scrollWindow=config.scrollWindow,element=config.element,fromRoot=config.fromRoot,resolver=createResolver({axis:new AxisResolver(!config.horizontal),windowElement:resolveContainerElement(scrollContainer,scrollWindow,element,fromRoot)}),stats=calculatePoints(element,resolver),scrollState={lastScrollPosition:0,lastTotalToScroll:0,totalToScroll:stats.totalToScroll,isTriggeredTotal:!1};return attachScrollEvent({container:resolver.container,mergeMap:function(){return calculatePoints(element,resolver)},scrollHandler:function(positionStats){return handleOnScroll(scrollState,positionStats,config)},throttleDuration:config.throttle})}function attachScrollEvent(options){return rxjs_Observable.Observable.fromEvent(options.container,"scroll").sampleTime(options.throttleDuration).mergeMap(function(ev){return rxjs_Observable.Observable.of(options.mergeMap(ev))}).subscribe(options.scrollHandler)}function handleOnScroll(scrollState,positionStats,config){var distance={down:config.downDistance,up:config.upDistance},_a=getScrollStats(scrollState.lastScrollPosition,positionStats,{distance:distance}),isScrollingDown=_a.isScrollingDown,shouldFireScrollEvent$$1=_a.shouldFireScrollEvent,scrollConfig={alwaysCallback:config.alwaysCallback,shouldFireScrollEvent:shouldFireScrollEvent$$1};updateScrollState(scrollState,positionStats.scrolledUntilNow,positionStats.totalToScroll),shouldTriggerEvents(scrollConfig)&&!scrollState.isTriggeredTotal&&(updateTriggeredFlag(scrollState,!0),triggerEvents(config.events,isScrollingDown,positionStats.scrolledUntilNow))}var AxisResolver=function(){function AxisResolver(vertical){void 0===vertical&&(vertical=!0),this.vertical=vertical}return AxisResolver.prototype.clientHeightKey=function(){return this.vertical?"clientHeight":"clientWidth"},AxisResolver.prototype.offsetHeightKey=function(){return this.vertical?"offsetHeight":"offsetWidth"},AxisResolver.prototype.scrollHeightKey=function(){return this.vertical?"scrollHeight":"scrollWidth"},AxisResolver.prototype.pageYOffsetKey=function(){return this.vertical?"pageYOffset":"pageXOffset"},AxisResolver.prototype.offsetTopKey=function(){return this.vertical?"offsetTop":"offsetLeft"},AxisResolver.prototype.scrollTopKey=function(){return this.vertical?"scrollTop":"scrollLeft"},AxisResolver.prototype.topKey=function(){return this.vertical?"top":"left"},AxisResolver}(),InfiniteScrollDirective=function(){function InfiniteScrollDirective(element,zone){this.element=element,this.zone=zone,this.scrolled=new _angular_core.EventEmitter,this.scrolledUp=new _angular_core.EventEmitter,this.infiniteScrollDistance=2,this.infiniteScrollUpDistance=1.5,this.infiniteScrollThrottle=300,this.infiniteScrollDisabled=!1,this.infiniteScrollContainer=null,this.scrollWindow=!0,this.immediateCheck=!1,this.horizontal=!1,this.alwaysCallback=!1,this.fromRoot=!1}return InfiniteScrollDirective.prototype.ngAfterViewInit=function(){this.infiniteScrollDisabled||this.setup()},InfiniteScrollDirective.prototype.ngOnChanges=function(_a){var infiniteScrollContainer=_a.infiniteScrollContainer,infiniteScrollDisabled=_a.infiniteScrollDisabled,infiniteScrollDistance=_a.infiniteScrollDistance,containerChanged=inputPropChanged(infiniteScrollContainer),disabledChanged=inputPropChanged(infiniteScrollDisabled),distanceChanged=inputPropChanged(infiniteScrollDistance),shouldSetup=!disabledChanged&&!this.infiniteScrollDisabled||disabledChanged&&!infiniteScrollDisabled.currentValue||distanceChanged;(containerChanged||disabledChanged||distanceChanged)&&(this.destroyScroller(),shouldSetup&&this.setup())},InfiniteScrollDirective.prototype.setup=function(){var _this=this;hasWindowDefined()&&this.zone.runOutsideAngular(function(){_this.disposeScroller=createScroller({fromRoot:_this.fromRoot,alwaysCallback:_this.alwaysCallback,disable:_this.infiniteScrollDisabled,downDistance:_this.infiniteScrollDistance,element:_this.element,events:{down:function(event){return _this.zone.run(function(){return _this.scrolled.emit(event)})},up:function(event){return _this.zone.run(function(){return _this.scrolledUp.emit(event)})}},horizontal:_this.horizontal,scrollContainer:_this.infiniteScrollContainer,scrollWindow:_this.scrollWindow,throttle:_this.infiniteScrollThrottle,upDistance:_this.infiniteScrollUpDistance})})},InfiniteScrollDirective.prototype.ngOnDestroy=function(){this.destroyScroller()},InfiniteScrollDirective.prototype.destroyScroller=function(){this.disposeScroller&&this.disposeScroller.unsubscribe()},InfiniteScrollDirective}();InfiniteScrollDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[infiniteScroll], [infinite-scroll], [data-infinite-scroll]"}]}],InfiniteScrollDirective.ctorParameters=function(){return[{type:_angular_core.ElementRef},{type:_angular_core.NgZone}]},InfiniteScrollDirective.propDecorators={scrolled:[{type:_angular_core.Output}],scrolledUp:[{type:_angular_core.Output}],infiniteScrollDistance:[{type:_angular_core.Input}],infiniteScrollUpDistance:[{type:_angular_core.Input}],infiniteScrollThrottle:[{type:_angular_core.Input}],infiniteScrollDisabled:[{type:_angular_core.Input}],infiniteScrollContainer:[{type:_angular_core.Input}],scrollWindow:[{type:_angular_core.Input}],immediateCheck:[{type:_angular_core.Input}],horizontal:[{type:_angular_core.Input}],alwaysCallback:[{type:_angular_core.Input}],fromRoot:[{type:_angular_core.Input}]};var InfiniteScrollModule=function(){function InfiniteScrollModule(){}return InfiniteScrollModule}();InfiniteScrollModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[InfiniteScrollDirective],exports:[InfiniteScrollDirective],imports:[],providers:[]}]}],InfiniteScrollModule.ctorParameters=function(){return[]},exports.InfiniteScrollDirective=InfiniteScrollDirective,exports.InfiniteScrollModule=InfiniteScrollModule,Object.defineProperty(exports,"__esModule",{value:!0})});
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs/add/observable/fromEvent"),require("rxjs/add/observable/of"),require("rxjs/add/operator/filter"),require("rxjs/add/operator/mergeMap"),require("rxjs/add/operator/map"),require("rxjs/add/operator/do"),require("rxjs/add/operator/sampleTime"),require("rxjs/Observable"),require("rxjs/observable/of")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/add/observable/fromEvent","rxjs/add/observable/of","rxjs/add/operator/filter","rxjs/add/operator/mergeMap","rxjs/add/operator/map","rxjs/add/operator/do","rxjs/add/operator/sampleTime","rxjs/Observable","rxjs/observable/of"],factory):factory((global.ng=global.ng||{},global.ng.ngxInfiniteScroll=global.ng.ngxInfiniteScroll||{}),global.ng.core,null,null,null,null,null,null,null,global.Rx,global.rxjs_observable_of)}(this,function(exports,_angular_core,rxjs_add_observable_fromEvent,rxjs_add_observable_of,rxjs_add_operator_filter,rxjs_add_operator_mergeMap,rxjs_add_operator_map,rxjs_add_operator_do,rxjs_add_operator_sampleTime,rxjs_Observable,rxjs_observable_of){"use strict";function resolveContainerElement(selector,scrollWindow,defaultElement,fromRoot){var hasWindow=window&&!!window.document&&window.document.documentElement,container=hasWindow&&scrollWindow?window:defaultElement;if(selector){if(!(container=selector&&hasWindow&&"string"==typeof selector?findElement(selector,defaultElement.nativeElement,fromRoot):selector))throw new Error("ngx-infinite-scroll {resolveContainerElement()}: selector for")}return container}function findElement(selector,customRoot,fromRoot){return(fromRoot?window.document:customRoot).querySelector(selector)}function inputPropChanged(prop){return prop&&!prop.firstChange}function hasWindowDefined(){return"undefined"!=typeof window}function shouldTriggerEvents(alwaysCallback,shouldFireScrollEvent,isTriggeredCurrentTotal){return(alwaysCallback||shouldFireScrollEvent)&&!isTriggeredCurrentTotal}function createResolver(_a){var windowElement=_a.windowElement;return createResolverWithContainer({axis:_a.axis,isWindow:isElementWindow(windowElement)},windowElement)}function createResolverWithContainer(resolver,windowElement){var container=resolver.isWindow||windowElement&&!windowElement.nativeElement?windowElement:windowElement.nativeElement;return Object.assign({},resolver,{container:container})}function isElementWindow(windowElement){return["Window","global"].some(function(obj){return Object.prototype.toString.call(windowElement).includes(obj)})}function getDocumentElement(isContainerWindow,windowElement){return isContainerWindow?windowElement.document.documentElement:null}function calculatePoints(element,resolver){var height=extractHeightForElement(resolver);return resolver.isWindow?calculatePointsForWindow(height,element,resolver):calculatePointsForElement(height,element,resolver)}function calculatePointsForWindow(height,element,resolver){var axis=resolver.axis,container=resolver.container,isWindow=resolver.isWindow,_a=extractHeightPropKeys(axis),offsetHeightKey=_a.offsetHeightKey,clientHeightKey=_a.clientHeightKey,scrolledUntilNow=height+getElementPageYOffset(getDocumentElement(isWindow,container),axis,isWindow),nativeElementHeight=getElementHeight(element.nativeElement,isWindow,offsetHeightKey,clientHeightKey);return{height:height,scrolledUntilNow:scrolledUntilNow,totalToScroll:getElementOffsetTop(element.nativeElement,axis,isWindow)+nativeElementHeight}}function calculatePointsForElement(height,element,resolver){var axis=resolver.axis,container=resolver.container;return{height:height,scrolledUntilNow:container[axis.scrollTopKey()],totalToScroll:container[axis.scrollHeightKey()]}}function extractHeightPropKeys(axis){return{offsetHeightKey:axis.offsetHeightKey(),clientHeightKey:axis.clientHeightKey()}}function extractHeightForElement(_a){var container=_a.container,isWindow=_a.isWindow,axis=_a.axis,_b=extractHeightPropKeys(axis);return getElementHeight(container,isWindow,_b.offsetHeightKey,_b.clientHeightKey)}function getElementHeight(elem,isWindow,offsetHeightKey,clientHeightKey){return isNaN(elem[offsetHeightKey])?getDocumentElement(isWindow,elem)[clientHeightKey]:elem[offsetHeightKey]}function getElementOffsetTop(elem,axis,isWindow){var topKey=axis.topKey();if(elem.getBoundingClientRect)return elem.getBoundingClientRect()[topKey]+getElementPageYOffset(elem,axis,isWindow)}function getElementPageYOffset(elem,axis,isWindow){var pageYOffset=axis.pageYOffsetKey(),scrollTop=axis.scrollTopKey(),offsetTop=axis.offsetTopKey();return isNaN(window[pageYOffset])?getDocumentElement(isWindow,elem)[scrollTop]:elem.ownerDocument?elem.ownerDocument.defaultView[pageYOffset]:elem[offsetTop]}function shouldFireScrollEvent(container,distance,scrollingDown){var remaining,containerBreakpoint;return scrollingDown?(remaining=(container.totalToScroll-container.scrolledUntilNow)/container.totalToScroll,containerBreakpoint=distance.down/10):(remaining=container.scrolledUntilNow/container.totalToScroll,containerBreakpoint=distance.up/10),remaining<=containerBreakpoint}function isScrollingDownwards(lastScrollPosition,container){return lastScrollPosition<container.scrolledUntilNow}function getScrollStats(lastScrollPosition,container,distance){var isScrollingDown=isScrollingDownwards(lastScrollPosition,container);return{shouldFireScrollEvent:shouldFireScrollEvent(container,distance,isScrollingDown),isScrollingDown:isScrollingDown}}function updateScrollPosition(position,scrollState){return scrollState.lastScrollPosition=position}function updateTotalToScroll(totalToScroll,scrollState){scrollState.lastTotalToScroll=scrollState.totalToScroll,scrollState.totalToScroll=totalToScroll}function isSameTotalToScroll(scrollState){return scrollState.totalToScroll===scrollState.lastTotalToScroll}function updateTriggeredFlag(scrollState,triggered){scrollState.isTriggeredTotal=triggered}function updateScrollState(scrollState,scrolledUntilNow,totalToScroll){updateScrollPosition(scrolledUntilNow,scrollState),updateTotalToScroll(totalToScroll,scrollState),isSameTotalToScroll(scrollState)||updateTriggeredFlag(scrollState,!1)}function createScroller(config){var scrollContainer=config.scrollContainer,scrollWindow=config.scrollWindow,element=config.element,fromRoot=config.fromRoot,resolver=createResolver({axis:new AxisResolver(!config.horizontal),windowElement:resolveContainerElement(scrollContainer,scrollWindow,element,fromRoot)}),stats=calculatePoints(element,resolver),scrollState={lastScrollPosition:0,lastTotalToScroll:0,totalToScroll:stats.totalToScroll,isTriggeredTotal:!1},options={container:resolver.container,throttle:config.throttle},distance={up:config.upDistance,down:config.downDistance};return attachScrollEvent(options).mergeMap(function(ev){return rxjs_observable_of.of(calculatePoints(element,resolver))}).map(function(positionStats){return toInfiniteScrollParams(scrollState.lastScrollPosition,positionStats,distance)}).do(function(_a){var positionStats=_a.positionStats;return updateScrollState(scrollState,positionStats.scrolledUntilNow,positionStats.totalToScroll)}).filter(function(_a){return shouldTriggerEvents(_a.shouldFireScrollEvent,config.alwaysCallback,scrollState.isTriggeredTotal)}).do(function(){updateTriggeredFlag(scrollState,!0)}).map(toInfiniteScrollAction)}function attachScrollEvent(options){return rxjs_Observable.Observable.fromEvent(options.container,"scroll").sampleTime(options.throttle)}function toInfiniteScrollParams(lastScrollPosition,positionStats,distance){var _a=getScrollStats(lastScrollPosition,positionStats,distance);return{isScrollingDown:_a.isScrollingDown,shouldFireScrollEvent:_a.shouldFireScrollEvent,positionStats:positionStats}}function toInfiniteScrollAction(response){var isScrollingDown=response.isScrollingDown,currentScrollPosition=response.positionStats.scrolledUntilNow;return{type:isScrollingDown?InfiniteScrollActions.DOWN:InfiniteScrollActions.UP,payload:{currentScrollPosition:currentScrollPosition}}}var AxisResolver=function(){function AxisResolver(vertical){void 0===vertical&&(vertical=!0),this.vertical=vertical}return AxisResolver.prototype.clientHeightKey=function(){return this.vertical?"clientHeight":"clientWidth"},AxisResolver.prototype.offsetHeightKey=function(){return this.vertical?"offsetHeight":"offsetWidth"},AxisResolver.prototype.scrollHeightKey=function(){return this.vertical?"scrollHeight":"scrollWidth"},AxisResolver.prototype.pageYOffsetKey=function(){return this.vertical?"pageYOffset":"pageXOffset"},AxisResolver.prototype.offsetTopKey=function(){return this.vertical?"offsetTop":"offsetLeft"},AxisResolver.prototype.scrollTopKey=function(){return this.vertical?"scrollTop":"scrollLeft"},AxisResolver.prototype.topKey=function(){return this.vertical?"top":"left"},AxisResolver}(),InfiniteScrollActions={DOWN:"[NGX_ISE] DOWN",UP:"[NGX_ISE] UP"},InfiniteScrollDirective=function(){function InfiniteScrollDirective(element,zone){this.element=element,this.zone=zone,this.scrolled=new _angular_core.EventEmitter,this.scrolledUp=new _angular_core.EventEmitter,this.infiniteScrollDistance=2,this.infiniteScrollUpDistance=1.5,this.infiniteScrollThrottle=300,this.infiniteScrollDisabled=!1,this.infiniteScrollContainer=null,this.scrollWindow=!0,this.immediateCheck=!1,this.horizontal=!1,this.alwaysCallback=!1,this.fromRoot=!1}return InfiniteScrollDirective.prototype.ngAfterViewInit=function(){this.infiniteScrollDisabled||this.setup()},InfiniteScrollDirective.prototype.ngOnChanges=function(_a){var infiniteScrollContainer=_a.infiniteScrollContainer,infiniteScrollDisabled=_a.infiniteScrollDisabled,infiniteScrollDistance=_a.infiniteScrollDistance,containerChanged=inputPropChanged(infiniteScrollContainer),disabledChanged=inputPropChanged(infiniteScrollDisabled),distanceChanged=inputPropChanged(infiniteScrollDistance),shouldSetup=!disabledChanged&&!this.infiniteScrollDisabled||disabledChanged&&!infiniteScrollDisabled.currentValue||distanceChanged;(containerChanged||disabledChanged||distanceChanged)&&(this.destroyScroller(),shouldSetup&&this.setup())},InfiniteScrollDirective.prototype.setup=function(){var _this=this;hasWindowDefined()&&this.zone.runOutsideAngular(function(){_this.disposeScroller=createScroller({fromRoot:_this.fromRoot,alwaysCallback:_this.alwaysCallback,disable:_this.infiniteScrollDisabled,downDistance:_this.infiniteScrollDistance,element:_this.element,horizontal:_this.horizontal,scrollContainer:_this.infiniteScrollContainer,scrollWindow:_this.scrollWindow,throttle:_this.infiniteScrollThrottle,upDistance:_this.infiniteScrollUpDistance}).subscribe(function(payload){return _this.zone.run(function(){return _this.handleOnScroll(payload)})})})},InfiniteScrollDirective.prototype.handleOnScroll=function(_a){var type=_a.type,payload=_a.payload;switch(type){case InfiniteScrollActions.DOWN:return this.scrolled.emit(payload);case InfiniteScrollActions.UP:return this.scrolledUp.emit(payload);default:return}},InfiniteScrollDirective.prototype.ngOnDestroy=function(){this.destroyScroller()},InfiniteScrollDirective.prototype.destroyScroller=function(){this.disposeScroller&&this.disposeScroller.unsubscribe()},InfiniteScrollDirective}();InfiniteScrollDirective.decorators=[{type:_angular_core.Directive,args:[{selector:"[infiniteScroll], [infinite-scroll], [data-infinite-scroll]"}]}],InfiniteScrollDirective.ctorParameters=function(){return[{type:_angular_core.ElementRef},{type:_angular_core.NgZone}]},InfiniteScrollDirective.propDecorators={scrolled:[{type:_angular_core.Output}],scrolledUp:[{type:_angular_core.Output}],infiniteScrollDistance:[{type:_angular_core.Input}],infiniteScrollUpDistance:[{type:_angular_core.Input}],infiniteScrollThrottle:[{type:_angular_core.Input}],infiniteScrollDisabled:[{type:_angular_core.Input}],infiniteScrollContainer:[{type:_angular_core.Input}],scrollWindow:[{type:_angular_core.Input}],immediateCheck:[{type:_angular_core.Input}],horizontal:[{type:_angular_core.Input}],alwaysCallback:[{type:_angular_core.Input}],fromRoot:[{type:_angular_core.Input}]};var InfiniteScrollModule=function(){function InfiniteScrollModule(){}return InfiniteScrollModule}();InfiniteScrollModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[InfiniteScrollDirective],exports:[InfiniteScrollDirective],imports:[],providers:[]}]}],InfiniteScrollModule.ctorParameters=function(){return[]},exports.InfiniteScrollDirective=InfiniteScrollDirective,exports.InfiniteScrollModule=InfiniteScrollModule,Object.defineProperty(exports,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-infinite-scroll.umd.min.js.map

@@ -6,4 +6,7 @@ import { Directive, ElementRef, EventEmitter, Input, NgModule, NgZone, Output } from '@angular/core';

import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/sampleTime';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
/**

@@ -92,23 +95,11 @@ * @param {?} selector

/**
* @param {?} __0
* @param {?} alwaysCallback
* @param {?} shouldFireScrollEvent
* @param {?} isTriggeredCurrentTotal
* @return {?}
*/
function shouldTriggerEvents(_a) {
var alwaysCallback = _a.alwaysCallback, shouldFireScrollEvent = _a.shouldFireScrollEvent;
return (alwaysCallback || shouldFireScrollEvent);
function shouldTriggerEvents(alwaysCallback, shouldFireScrollEvent, isTriggeredCurrentTotal) {
return (alwaysCallback || shouldFireScrollEvent) && !isTriggeredCurrentTotal;
}
/**
* @param {?} callbacks
* @param {?} isScrollingDown
* @param {?} scrolledUntilNow
* @return {?}
*/
function triggerEvents(callbacks, isScrollingDown, scrolledUntilNow) {
var /** @type {?} */ eventData = {
currentScrollPosition: scrolledUntilNow
};
var /** @type {?} */ callback = isScrollingDown ? callbacks.down : callbacks.up;
callback(eventData);
}
/**
* @param {?} __0

@@ -262,8 +253,7 @@ * @return {?}

* @param {?} container
* @param {?} config
* @param {?} distance
* @param {?} scrollingDown
* @return {?}
*/
function shouldFireScrollEvent(container, config, scrollingDown) {
var /** @type {?} */ distance = config.distance;
function shouldFireScrollEvent(container, distance, scrollingDown) {
var /** @type {?} */ remaining;

@@ -293,9 +283,9 @@ var /** @type {?} */ containerBreakpoint;

* @param {?} container
* @param {?} config
* @param {?} distance
* @return {?}
*/
function getScrollStats(lastScrollPosition, container, config) {
function getScrollStats(lastScrollPosition, container, distance) {
var /** @type {?} */ isScrollingDown = isScrollingDownwards(lastScrollPosition, container);
return {
shouldFireScrollEvent: shouldFireScrollEvent(container, config, isScrollingDown),
shouldFireScrollEvent: shouldFireScrollEvent(container, distance, isScrollingDown),
isScrollingDown: isScrollingDown

@@ -369,7 +359,23 @@ };

container: resolver.container,
mergeMap: function () { return calculatePoints(element, resolver); },
scrollHandler: function (positionStats) { return handleOnScroll(scrollState, positionStats, config); },
throttleDuration: config.throttle
throttle: config.throttle
};
return attachScrollEvent(options);
var /** @type {?} */ distance = {
up: config.upDistance,
down: config.downDistance
};
return attachScrollEvent(options)
.mergeMap(function (ev) { return of(calculatePoints(element, resolver)); })
.map(function (positionStats) { return toInfiniteScrollParams(scrollState.lastScrollPosition, positionStats, distance); })
.do(function (_a) {
var positionStats = _a.positionStats;
return updateScrollState(scrollState, positionStats.scrolledUntilNow, positionStats.totalToScroll);
})
.filter(function (_a) {
var shouldFireScrollEvent$$1 = _a.shouldFireScrollEvent;
return shouldTriggerEvents(shouldFireScrollEvent$$1, config.alwaysCallback, scrollState.isTriggeredTotal);
})
.do(function () {
updateTriggeredFlag(scrollState, true);
})
.map(toInfiniteScrollAction);
}

@@ -381,29 +387,36 @@ /**

function attachScrollEvent(options) {
return Observable.fromEvent(options.container, 'scroll')
.sampleTime(options.throttleDuration)
.mergeMap(function (ev) { return Observable.of(options.mergeMap(ev)); })
.subscribe(options.scrollHandler);
return Observable
.fromEvent(options.container, 'scroll')
.sampleTime(options.throttle);
}
/**
* @param {?} scrollState
* @param {?} lastScrollPosition
* @param {?} positionStats
* @param {?} config
* @param {?} distance
* @return {?}
*/
function handleOnScroll(scrollState, positionStats, config) {
var /** @type {?} */ distance = {
down: config.downDistance,
up: config.upDistance
function toInfiniteScrollParams(lastScrollPosition, positionStats, distance) {
var _a = getScrollStats(lastScrollPosition, positionStats, distance), isScrollingDown = _a.isScrollingDown, shouldFireScrollEvent$$1 = _a.shouldFireScrollEvent;
return {
isScrollingDown: isScrollingDown,
shouldFireScrollEvent: shouldFireScrollEvent$$1,
positionStats: positionStats
};
var _a = getScrollStats(scrollState.lastScrollPosition, positionStats, { distance: distance }), isScrollingDown = _a.isScrollingDown, shouldFireScrollEvent$$1 = _a.shouldFireScrollEvent;
var /** @type {?} */ scrollConfig = {
alwaysCallback: config.alwaysCallback,
shouldFireScrollEvent: shouldFireScrollEvent$$1
}
var InfiniteScrollActions = {
DOWN: '[NGX_ISE] DOWN',
UP: '[NGX_ISE] UP'
};
/**
* @param {?} response
* @return {?}
*/
function toInfiniteScrollAction(response) {
var isScrollingDown = response.isScrollingDown, currentScrollPosition = response.positionStats.scrolledUntilNow;
return {
type: isScrollingDown ? InfiniteScrollActions.DOWN : InfiniteScrollActions.UP,
payload: {
currentScrollPosition: currentScrollPosition
}
};
updateScrollState(scrollState, positionStats.scrolledUntilNow, positionStats.totalToScroll);
var /** @type {?} */ shouldTrigger = shouldTriggerEvents(scrollConfig);
if (shouldTrigger && !scrollState.isTriggeredTotal) {
updateTriggeredFlag(scrollState, true);
triggerEvents(config.events, isScrollingDown, positionStats.scrolledUntilNow);
}
}

@@ -470,8 +483,2 @@ var InfiniteScrollDirective = (function () {

element: _this.element,
events: {
// tslint:disable-next-line:arrow-parens
down: function (event) { return _this.zone.run(function () { return _this.scrolled.emit(event); }); },
// tslint:disable-next-line:arrow-parens
up: function (event) { return _this.zone.run(function () { return _this.scrolledUp.emit(event); }); }
},
horizontal: _this.horizontal,

@@ -482,3 +489,3 @@ scrollContainer: _this.infiniteScrollContainer,

upDistance: _this.infiniteScrollUpDistance
});
}).subscribe(function (payload) { return _this.zone.run(function () { return _this.handleOnScroll(payload); }); });
});

@@ -488,4 +495,19 @@ }

/**
* @param {?} __0
* @return {?}
*/
InfiniteScrollDirective.prototype.handleOnScroll = function (_a) {
var type = _a.type, payload = _a.payload;
switch (type) {
case InfiniteScrollActions.DOWN:
return this.scrolled.emit(payload);
case InfiniteScrollActions.UP:
return this.scrolledUp.emit(payload);
default:
return;
}
};
/**
* @return {?}
*/
InfiniteScrollDirective.prototype.ngOnDestroy = function () {

@@ -492,0 +514,0 @@ this.destroyScroller();

@@ -6,4 +6,7 @@ import { Directive, ElementRef, EventEmitter, Input, NgModule, NgZone, Output } from '@angular/core';

import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/sampleTime';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';

@@ -93,21 +96,10 @@ /**

/**
* @param {?} __0
* @param {?} alwaysCallback
* @param {?} shouldFireScrollEvent
* @param {?} isTriggeredCurrentTotal
* @return {?}
*/
function shouldTriggerEvents({ alwaysCallback, shouldFireScrollEvent }) {
return (alwaysCallback || shouldFireScrollEvent);
function shouldTriggerEvents(alwaysCallback, shouldFireScrollEvent, isTriggeredCurrentTotal) {
return (alwaysCallback || shouldFireScrollEvent) && !isTriggeredCurrentTotal;
}
/**
* @param {?} callbacks
* @param {?} isScrollingDown
* @param {?} scrolledUntilNow
* @return {?}
*/
function triggerEvents(callbacks, isScrollingDown, scrolledUntilNow) {
const /** @type {?} */ eventData = {
currentScrollPosition: scrolledUntilNow
};
const /** @type {?} */ callback = isScrollingDown ? callbacks.down : callbacks.up;
callback(eventData);
}

@@ -262,8 +254,7 @@ /**

* @param {?} container
* @param {?} config
* @param {?} distance
* @param {?} scrollingDown
* @return {?}
*/
function shouldFireScrollEvent(container, config, scrollingDown) {
const /** @type {?} */ distance = config.distance;
function shouldFireScrollEvent(container, distance, scrollingDown) {
let /** @type {?} */ remaining;

@@ -293,9 +284,9 @@ let /** @type {?} */ containerBreakpoint;

* @param {?} container
* @param {?} config
* @param {?} distance
* @return {?}
*/
function getScrollStats(lastScrollPosition, container, config) {
function getScrollStats(lastScrollPosition, container, distance) {
const /** @type {?} */ isScrollingDown = isScrollingDownwards(lastScrollPosition, container);
return {
shouldFireScrollEvent: shouldFireScrollEvent(container, config, isScrollingDown),
shouldFireScrollEvent: shouldFireScrollEvent(container, distance, isScrollingDown),
isScrollingDown

@@ -370,7 +361,17 @@ };

container: resolver.container,
mergeMap: () => calculatePoints(element, resolver),
scrollHandler: (positionStats) => handleOnScroll(scrollState, positionStats, config),
throttleDuration: config.throttle
throttle: config.throttle
};
return attachScrollEvent(options);
const /** @type {?} */ distance = {
up: config.upDistance,
down: config.downDistance
};
return attachScrollEvent(options)
.mergeMap((ev) => of(calculatePoints(element, resolver)))
.map((positionStats) => toInfiniteScrollParams(scrollState.lastScrollPosition, positionStats, distance))
.do(({ positionStats }) => updateScrollState(scrollState, positionStats.scrolledUntilNow, positionStats.totalToScroll))
.filter(({ shouldFireScrollEvent: shouldFireScrollEvent$$1 }) => shouldTriggerEvents(shouldFireScrollEvent$$1, config.alwaysCallback, scrollState.isTriggeredTotal))
.do(() => {
updateTriggeredFlag(scrollState, true);
})
.map(toInfiniteScrollAction);
}

@@ -382,29 +383,36 @@ /**

function attachScrollEvent(options) {
return Observable.fromEvent(options.container, 'scroll')
.sampleTime(options.throttleDuration)
.mergeMap((ev) => Observable.of(options.mergeMap(ev)))
.subscribe(options.scrollHandler);
return Observable
.fromEvent(options.container, 'scroll')
.sampleTime(options.throttle);
}
/**
* @param {?} scrollState
* @param {?} lastScrollPosition
* @param {?} positionStats
* @param {?} config
* @param {?} distance
* @return {?}
*/
function handleOnScroll(scrollState, positionStats, config) {
const /** @type {?} */ distance = {
down: config.downDistance,
up: config.upDistance
function toInfiniteScrollParams(lastScrollPosition, positionStats, distance) {
const { isScrollingDown, shouldFireScrollEvent: shouldFireScrollEvent$$1 } = getScrollStats(lastScrollPosition, positionStats, distance);
return {
isScrollingDown,
shouldFireScrollEvent: shouldFireScrollEvent$$1,
positionStats
};
const { isScrollingDown, shouldFireScrollEvent: shouldFireScrollEvent$$1 } = getScrollStats(scrollState.lastScrollPosition, positionStats, { distance });
const /** @type {?} */ scrollConfig = {
alwaysCallback: config.alwaysCallback,
shouldFireScrollEvent: shouldFireScrollEvent$$1
}
const InfiniteScrollActions = {
DOWN: '[NGX_ISE] DOWN',
UP: '[NGX_ISE] UP'
};
/**
* @param {?} response
* @return {?}
*/
function toInfiniteScrollAction(response) {
const { isScrollingDown, positionStats: { scrolledUntilNow: currentScrollPosition } } = response;
return {
type: isScrollingDown ? InfiniteScrollActions.DOWN : InfiniteScrollActions.UP,
payload: {
currentScrollPosition
}
};
updateScrollState(scrollState, positionStats.scrolledUntilNow, positionStats.totalToScroll);
const /** @type {?} */ shouldTrigger = shouldTriggerEvents(scrollConfig);
if (shouldTrigger && !scrollState.isTriggeredTotal) {
updateTriggeredFlag(scrollState, true);
triggerEvents(config.events, isScrollingDown, positionStats.scrolledUntilNow);
}
}

@@ -470,8 +478,2 @@

element: this.element,
events: {
// tslint:disable-next-line:arrow-parens
down: event => this.zone.run(() => this.scrolled.emit(event)),
// tslint:disable-next-line:arrow-parens
up: event => this.zone.run(() => this.scrolledUp.emit(event))
},
horizontal: this.horizontal,

@@ -482,3 +484,3 @@ scrollContainer: this.infiniteScrollContainer,

upDistance: this.infiniteScrollUpDistance
});
}).subscribe((payload) => this.zone.run(() => this.handleOnScroll(payload)));
});

@@ -488,4 +490,18 @@ }

/**
* @param {?} __0
* @return {?}
*/
handleOnScroll({ type, payload }) {
switch (type) {
case InfiniteScrollActions.DOWN:
return this.scrolled.emit(payload);
case InfiniteScrollActions.UP:
return this.scrolledUp.emit(payload);
default:
return;
}
}
/**
* @return {?}
*/
ngOnDestroy() {

@@ -492,0 +508,0 @@ this.destroyScroller();

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":3,"metadata":{"InfiniteScrollEvent":{"__symbolic":"interface"},"IPositionElements":{"__symbolic":"interface"},"IPositionStats":{"__symbolic":"interface"},"IScrollStats":{"__symbolic":"interface"},"IScrollerConfig":{"__symbolic":"interface"},"IResolver":{"__symbolic":"interface"},"InfiniteScrollDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[infiniteScroll], [infinite-scroll], [data-infinite-scroll]"}]}],"members":{"scrolled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"scrolledUp":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"infiniteScrollDistance":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"infiniteScrollUpDistance":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"infiniteScrollThrottle":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"infiniteScrollDisabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"infiniteScrollContainer":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"scrollWindow":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"immediateCheck":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"horizontal":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"alwaysCallback":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fromRoot":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"NgZone"}]}],"ngAfterViewInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"setup":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"destroyScroller":[{"__symbolic":"method"}]}},"InfiniteScrollModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"InfiniteScrollDirective"}],"exports":[{"__symbolic":"reference","name":"InfiniteScrollDirective"}],"imports":[],"providers":[]}]}],"members":{}}},"origins":{"ContainerRef":"./src/models","InfiniteScrollEvent":"./src/models","IPositionElements":"./src/models","IPositionStats":"./src/models","IScrollStats":"./src/models","IScrollerConfig":"./src/models","IResolver":"./src/models","InfiniteScrollDirective":"./src/modules/infinite-scroll.directive","InfiniteScrollModule":"./src/modules/ngx-infinite-scroll.module"},"importAs":"ngx-infinite-scroll"}
{"__symbolic":"module","version":3,"metadata":{"InfiniteScrollEvent":{"__symbolic":"interface"},"IPositionElements":{"__symbolic":"interface"},"IPositionStats":{"__symbolic":"interface"},"IResolver":{"__symbolic":"interface"},"InfiniteScrollDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[infiniteScroll], [infinite-scroll], [data-infinite-scroll]"}]}],"members":{"scrolled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"scrolledUp":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"infiniteScrollDistance":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"infiniteScrollUpDistance":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"infiniteScrollThrottle":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"infiniteScrollDisabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"infiniteScrollContainer":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"scrollWindow":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"immediateCheck":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"horizontal":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"alwaysCallback":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fromRoot":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"NgZone"}]}],"ngAfterViewInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"setup":[{"__symbolic":"method"}],"handleOnScroll":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"destroyScroller":[{"__symbolic":"method"}]}},"InfiniteScrollModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"InfiniteScrollDirective"}],"exports":[{"__symbolic":"reference","name":"InfiniteScrollDirective"}],"imports":[],"providers":[]}]}],"members":{}}},"origins":{"ContainerRef":"./src/models","InfiniteScrollEvent":"./src/models","IPositionElements":"./src/models","IPositionStats":"./src/models","IResolver":"./src/models","InfiniteScrollDirective":"./src/modules/infinite-scroll.directive","InfiniteScrollModule":"./src/modules/ngx-infinite-scroll.module"},"importAs":"ngx-infinite-scroll"}
{
"name": "ngx-infinite-scroll",
"version": "0.8.0",
"version": "0.8.1",
"description": "An infinite scroll directive for Angular compatible with AoT compilation and Tree shaking",

@@ -5,0 +5,0 @@ "main": "./bundles/ngx-infinite-scroll.umd.js",

@@ -15,13 +15,6 @@ import { ElementRef } from '@angular/core';

}
export interface IScrollerConfig {
distance: {
down: number;
up: number;
};
scrollParent?: ContainerRef;
export interface IScrollerDistance {
down?: number;
up?: number;
}
export interface IScrollStats {
isScrollingDown: boolean;
shouldScroll: boolean;
}
export interface IScrollState {

@@ -38,1 +31,26 @@ lastTotalToScroll: number;

}
export interface IScrollRegisterConfig {
container: ContainerRef;
throttle: number;
}
export interface IScroller {
fromRoot: boolean;
horizontal: boolean;
disable: boolean;
throttle: number;
scrollWindow: boolean;
element: ElementRef;
scrollContainer: string | ElementRef;
alwaysCallback: boolean;
downDistance: number;
upDistance: number;
}
export interface IScrollParams {
isScrollingDown: boolean;
shouldFireScrollEvent: boolean;
positionStats: IPositionStats;
}
export interface IInfiniteScrollAction {
type: string;
payload: InfiniteScrollEvent;
}
import { AfterViewInit, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
import { InfiniteScrollEvent } from '../models';
import { InfiniteScrollEvent, IInfiniteScrollAction } from '../models';
export declare class InfiniteScrollDirective implements OnDestroy, OnChanges, AfterViewInit {

@@ -23,4 +23,5 @@ private element;

setup(): void;
handleOnScroll({type, payload}: IInfiniteScrollAction): void;
ngOnDestroy(): void;
destroyScroller(): void;
}

@@ -1,3 +0,3 @@

export { ContainerRef, InfiniteScrollEvent, IPositionElements, IPositionStats, IScrollStats, IScrollerConfig, IResolver } from './models';
export { ContainerRef, InfiniteScrollEvent, IPositionElements, IPositionStats, IResolver } from './models';
export { InfiniteScrollDirective } from './modules/infinite-scroll.directive';
export { InfiniteScrollModule } from './modules/ngx-infinite-scroll.module';

@@ -21,3 +21,2 @@ import { IPositionStats } from '../models';

}
export declare function shouldTriggerEvents({alwaysCallback, shouldFireScrollEvent}: IScrollConfig): boolean;
export declare function triggerEvents(callbacks: ITriggerEvents, isScrollingDown: boolean, scrolledUntilNow: number): void;
export declare function shouldTriggerEvents(alwaysCallback: boolean, shouldFireScrollEvent: boolean, isTriggeredCurrentTotal: boolean): boolean;

@@ -5,30 +5,14 @@ import 'rxjs/add/observable/fromEvent';

import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/sampleTime';
import { ElementRef } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { ContainerRef, IPositionStats, IScrollState } from '../models';
export interface IScrollRegisterConfig {
container: ContainerRef;
throttleDuration: number;
mergeMap: Function;
scrollHandler: (value: any) => void;
}
export interface IScroller {
fromRoot: boolean;
horizontal: boolean;
disable: boolean;
throttle: number;
scrollWindow: boolean;
element: ElementRef;
scrollContainer: string | ElementRef;
alwaysCallback: boolean;
downDistance: number;
upDistance: number;
events?: {
down: (ev) => any;
up: (ev) => any;
};
}
export declare function createScroller(config: IScroller): Subscription;
export declare function attachScrollEvent(options: IScrollRegisterConfig): Subscription;
export declare function handleOnScroll(scrollState: IScrollState, positionStats: IPositionStats, config: IScroller): void;
import { Observable } from 'rxjs/Observable';
import * as Models from '../models';
export declare function createScroller(config: Models.IScroller): Observable<Models.IInfiniteScrollAction>;
export declare function attachScrollEvent(options: Models.IScrollRegisterConfig): Observable<{}>;
export declare function toInfiniteScrollParams(lastScrollPosition: number, positionStats: Models.IPositionStats, distance: Models.IScrollerDistance): Models.IScrollParams;
export declare const InfiniteScrollActions: {
DOWN: string;
UP: string;
};
export declare function toInfiniteScrollAction(response: Models.IScrollParams): Models.IInfiniteScrollAction;

@@ -1,5 +0,5 @@

import { IPositionStats, IScrollerConfig, IScrollState } from '../models';
export declare function shouldFireScrollEvent(container: IPositionStats, config: IScrollerConfig, scrollingDown: boolean): boolean;
import { IPositionStats, IScrollState, IScrollerDistance } from '../models';
export declare function shouldFireScrollEvent(container: IPositionStats, distance: IScrollerDistance, scrollingDown: boolean): boolean;
export declare function isScrollingDownwards(lastScrollPosition: number, container: IPositionStats): boolean;
export declare function getScrollStats(lastScrollPosition: number, container: IPositionStats, config: IScrollerConfig): {
export declare function getScrollStats(lastScrollPosition: number, container: IPositionStats, distance: IScrollerDistance): {
shouldFireScrollEvent: boolean;

@@ -6,0 +6,0 @@ isScrollingDown: boolean;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc