ngx-infinite-scroll
Advanced tools
Comparing version 0.4.3-1 to 0.4.3
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/Observable'), 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')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/Observable', 'rxjs/add/observable/fromEvent', 'rxjs/add/observable/of', 'rxjs/add/operator/filter', 'rxjs/add/operator/mergeMap', 'rxjs/add/operator/sampleTime'], factory) : | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/Observable'), require('rxjs/add/observable/fromEvent'), require('rxjs/add/observable/of'), require('rxjs/add/operator/sampleTime'), require('rxjs/add/operator/filter'), require('rxjs/add/operator/mergeMap')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/Observable', 'rxjs/add/observable/fromEvent', 'rxjs/add/observable/of', 'rxjs/add/operator/sampleTime', 'rxjs/add/operator/filter', 'rxjs/add/operator/mergeMap'], factory) : | ||
(factory((global.ng = global.ng || {}, global.ng.ngxInfiniteScroll = global.ng.ngxInfiniteScroll || {}),global.ng.core,global.Rx)); | ||
@@ -296,3 +296,3 @@ }(this, (function (exports,_angular_core,rxjs_Observable) { 'use strict'; | ||
ScrollResolver.ctorParameters = function () { return []; }; | ||
var InfiniteScroll = (function () { | ||
var InfiniteScrollDirective = (function () { | ||
/** | ||
@@ -305,3 +305,3 @@ * @param {?} element | ||
*/ | ||
function InfiniteScroll(element, zone, positionResolverFactory, scrollRegister, scrollerResolver) { | ||
function InfiniteScrollDirective(element, zone, positionResolverFactory, scrollRegister, scrollerResolver) { | ||
this.element = element; | ||
@@ -314,28 +314,16 @@ this.zone = zone; | ||
this.scrolledUp = new _angular_core.EventEmitter(); | ||
this._distanceDown = 2; | ||
this._distanceUp = 1.5; | ||
this._throttle = 300; | ||
this._disabled = false; | ||
this._container = null; | ||
this.infiniteScrollDistance = 2; | ||
this.infiniteScrollUpDistance = 1.5; | ||
this.infiniteScrollThrottle = 300; | ||
this.infiniteScrollDisabled = false; | ||
this.infiniteScrollContainer = null; | ||
this.scrollWindow = true; | ||
this._immediate = false; | ||
this._horizontal = false; | ||
this._alwaysCallback = false; | ||
this.throttleType = 'throttle'; | ||
this.immediateCheck = false; | ||
this.horizontal = false; | ||
this.alwaysCallback = false; | ||
} | ||
Object.defineProperty(InfiniteScroll.prototype, "debounce", { | ||
/** | ||
* @param {?} value | ||
* @return {?} | ||
*/ | ||
set: function (value) { | ||
this.throttleType = value === '' || !!value ? 'debounce' : 'throttle'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* @return {?} | ||
*/ | ||
InfiniteScroll.prototype.ngOnInit = function () { | ||
InfiniteScrollDirective.prototype.ngOnInit = function () { | ||
var _this = this; | ||
@@ -345,12 +333,11 @@ if (typeof window !== 'undefined') { | ||
var /** @type {?} */ positionResolver_1 = this.positionResolverFactory.create({ | ||
windowElement: containerElement, | ||
horizontal: this._horizontal | ||
horizontal: this.horizontal, | ||
windowElement: containerElement | ||
}); | ||
var /** @type {?} */ options = { | ||
container: positionResolver_1.container, | ||
throttleType: this.throttleType, | ||
throttleDuration: this._throttle, | ||
filterBefore: function () { return !_this._disabled; }, | ||
filterBefore: function () { return !_this.infiniteScrollDisabled; }, | ||
mergeMap: function () { return positionResolver_1.calculatePoints(_this.element); }, | ||
scrollHandler: function (container) { return _this.handleOnScroll(container); } | ||
scrollHandler: function (container) { return _this.handleOnScroll(container); }, | ||
throttleDuration: this.infiniteScrollThrottle | ||
}; | ||
@@ -364,7 +351,7 @@ this.disposeScroller = this.scrollRegister.attachEvent(options); | ||
*/ | ||
InfiniteScroll.prototype.handleOnScroll = function (container) { | ||
InfiniteScrollDirective.prototype.handleOnScroll = function (container) { | ||
var /** @type {?} */ scrollResolverConfig = { | ||
distance: { | ||
down: this._distanceDown, | ||
up: this._distanceUp | ||
down: this.infiniteScrollDistance, | ||
up: this.infiniteScrollUpDistance | ||
} | ||
@@ -389,4 +376,4 @@ }; | ||
*/ | ||
InfiniteScroll.prototype.shouldTriggerEvents = function (shouldScroll) { | ||
return (this._alwaysCallback || shouldScroll) && !this._disabled; | ||
InfiniteScrollDirective.prototype.shouldTriggerEvents = function (shouldScroll) { | ||
return (this.alwaysCallback || shouldScroll) && !this.infiniteScrollDisabled; | ||
}; | ||
@@ -396,3 +383,3 @@ /** | ||
*/ | ||
InfiniteScroll.prototype.ngOnDestroy = function () { | ||
InfiniteScrollDirective.prototype.ngOnDestroy = function () { | ||
if (this.disposeScroller) { | ||
@@ -406,3 +393,3 @@ this.disposeScroller.unsubscribe(); | ||
*/ | ||
InfiniteScroll.prototype.onScrollDown = function (data) { | ||
InfiniteScrollDirective.prototype.onScrollDown = function (data) { | ||
var _this = this; | ||
@@ -416,3 +403,3 @@ if (data === void 0) { data = { currentScrollPosition: 0 }; } | ||
*/ | ||
InfiniteScroll.prototype.onScrollUp = function (data) { | ||
InfiniteScrollDirective.prototype.onScrollUp = function (data) { | ||
var _this = this; | ||
@@ -425,15 +412,19 @@ if (data === void 0) { data = { currentScrollPosition: 0 }; } | ||
*/ | ||
InfiniteScroll.prototype.resolveContainerElement = function () { | ||
if (this._container) { | ||
return typeof (this._container) === 'string' ? window.document.querySelector(this._container) : this._container; | ||
InfiniteScrollDirective.prototype.resolveContainerElement = function () { | ||
var /** @type {?} */ selector = this.infiniteScrollContainer; | ||
var /** @type {?} */ hasWindow = window && window.hasOwnProperty('document'); | ||
var /** @type {?} */ containerIsString = selector && hasWindow && typeof (this.infiniteScrollContainer) === 'string'; | ||
var /** @type {?} */ container = containerIsString | ||
? window.document.querySelector(selector) | ||
: selector; | ||
if (!selector) { | ||
container = this.scrollWindow ? window : this.element; | ||
} | ||
else { | ||
return this.scrollWindow ? window : this.element; | ||
} | ||
return container; | ||
}; | ||
return InfiniteScroll; | ||
return InfiniteScrollDirective; | ||
}()); | ||
InfiniteScroll.decorators = [ | ||
InfiniteScrollDirective.decorators = [ | ||
{ type: _angular_core.Directive, args: [{ | ||
selector: '[infiniteScroll],[infinite-scroll],[data-infinite-scroll]' | ||
selector: '[infiniteScroll], [infinite-scroll], [data-infinite-scroll]' | ||
},] }, | ||
@@ -444,3 +435,3 @@ ]; | ||
*/ | ||
InfiniteScroll.ctorParameters = function () { return [ | ||
InfiniteScrollDirective.ctorParameters = function () { return [ | ||
{ type: _angular_core.ElementRef, }, | ||
@@ -452,15 +443,14 @@ { type: _angular_core.NgZone, }, | ||
]; }; | ||
InfiniteScroll.propDecorators = { | ||
InfiniteScrollDirective.propDecorators = { | ||
'scrolled': [{ type: _angular_core.Output },], | ||
'scrolledUp': [{ type: _angular_core.Output },], | ||
'_distanceDown': [{ type: _angular_core.Input, args: ['infiniteScrollDistance',] },], | ||
'_distanceUp': [{ type: _angular_core.Input, args: ['infiniteScrollUpDistance',] },], | ||
'_throttle': [{ type: _angular_core.Input, args: ['infiniteScrollThrottle',] },], | ||
'_disabled': [{ type: _angular_core.Input, args: ['infiniteScrollDisabled',] },], | ||
'_container': [{ type: _angular_core.Input, args: ['infiniteScrollContainer',] },], | ||
'scrollWindow': [{ type: _angular_core.Input, args: ['scrollWindow',] },], | ||
'_immediate': [{ type: _angular_core.Input, args: ['immediateCheck',] },], | ||
'_horizontal': [{ type: _angular_core.Input, args: ['horizontal',] },], | ||
'_alwaysCallback': [{ type: _angular_core.Input, args: ['alwaysCallback',] },], | ||
'debounce': [{ type: _angular_core.Input },], | ||
'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 },], | ||
}; | ||
@@ -474,4 +464,4 @@ var InfiniteScrollModule = (function () { | ||
{ type: _angular_core.NgModule, args: [{ | ||
declarations: [InfiniteScroll], | ||
exports: [InfiniteScroll], | ||
declarations: [InfiniteScrollDirective], | ||
exports: [InfiniteScrollDirective], | ||
imports: [], | ||
@@ -492,3 +482,3 @@ providers: [ | ||
exports.InfiniteScrollModule = InfiniteScrollModule; | ||
exports.ɵa = InfiniteScroll; | ||
exports.ɵa = InfiniteScrollDirective; | ||
exports.ɵc = AxisResolverFactory; | ||
@@ -495,0 +485,0 @@ exports.ɵb = PositionResolverFactory; |
@@ -1,2 +0,2 @@ | ||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs/Observable"),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")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/Observable","rxjs/add/observable/fromEvent","rxjs/add/observable/of","rxjs/add/operator/filter","rxjs/add/operator/mergeMap","rxjs/add/operator/sampleTime"],factory):factory((global.ng=global.ng||{},global.ng.ngxInfiniteScroll=global.ng.ngxInfiniteScroll||{}),global.ng.core,global.Rx)}(this,function(exports,_angular_core,rxjs_Observable){"use strict";var AxisResolverFactory=function(){function AxisResolverFactory(){}return AxisResolverFactory.prototype.create=function(vertical){return void 0===vertical&&(vertical=!0),new AxisResolver(vertical)},AxisResolverFactory}();AxisResolverFactory.decorators=[{type:_angular_core.Injectable}],AxisResolverFactory.ctorParameters=function(){return[]};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}(),PositionResolverFactory=function(){function PositionResolverFactory(axisResolver){this.axisResolver=axisResolver}return PositionResolverFactory.prototype.create=function(options){return new PositionResolver(this.axisResolver.create(!options.horizontal),options)},PositionResolverFactory}();PositionResolverFactory.decorators=[{type:_angular_core.Injectable}],PositionResolverFactory.ctorParameters=function(){return[{type:AxisResolverFactory}]};var PositionResolver=function(){function PositionResolver(axis,options){this.axis=axis,this.options=options,this.resolveContainer(this.options.windowElement),this.defineContainer(this.options.windowElement)}return PositionResolver.prototype.defineContainer=function(windowElement){return this.resolveContainer(windowElement)||!windowElement.nativeElement?this.container=windowElement:this.container=windowElement.nativeElement,this.container},PositionResolver.prototype.resolveContainer=function(windowElement){var isContainerWindow=Object.prototype.toString.call(windowElement).includes("Window");return this.isContainerWindow=isContainerWindow,isContainerWindow},PositionResolver.prototype.getDocumentElement=function(){return this.isContainerWindow?this.options.windowElement.document.documentElement:null},PositionResolver.prototype.calculatePoints=function(element){return this.isContainerWindow?this.calculatePointsForWindow(element):this.calculatePointsForElement(element)},PositionResolver.prototype.calculatePointsForWindow=function(element){var height=this.height(this.container);return{height:height,scrolledUntilNow:height+this.pageYOffset(this.getDocumentElement()),totalToScroll:this.offsetTop(element.nativeElement)+this.height(element.nativeElement)}},PositionResolver.prototype.calculatePointsForElement=function(element){var scrollTop=this.axis.scrollTopKey(),scrollHeight=this.axis.scrollHeightKey(),container=this.container,height=this.height(container),scrolledUntilNow=container[scrollTop],offsetTop=this.offsetTop(container);return void 0!==offsetTop&&offsetTop,{height:height,scrolledUntilNow:scrolledUntilNow,totalToScroll:container[scrollHeight]}},PositionResolver.prototype.height=function(elem){var offsetHeight=this.axis.offsetHeightKey(),clientHeight=this.axis.clientHeightKey();return isNaN(elem[offsetHeight])?this.getDocumentElement()[clientHeight]:elem[offsetHeight]},PositionResolver.prototype.offsetTop=function(elem){var top=this.axis.topKey();if(elem.getBoundingClientRect)return elem.getBoundingClientRect()[top]+this.pageYOffset(elem)},PositionResolver.prototype.pageYOffset=function(elem){var pageYOffset=this.axis.pageYOffsetKey(),scrollTop=this.axis.scrollTopKey(),offsetTop=this.axis.offsetTopKey();return isNaN(window[pageYOffset])?this.getDocumentElement()[scrollTop]:elem.ownerDocument?elem.ownerDocument.defaultView[pageYOffset]:elem[offsetTop]},PositionResolver}(),ScrollRegister=function(){function ScrollRegister(){}return ScrollRegister.prototype.attachEvent=function(options){return rxjs_Observable.Observable.fromEvent(options.container,"scroll").sampleTime(options.throttleDuration).filter(options.filterBefore).mergeMap(function(ev){return rxjs_Observable.Observable.of(options.mergeMap(ev))}).subscribe(options.scrollHandler)},ScrollRegister}();ScrollRegister.decorators=[{type:_angular_core.Injectable}],ScrollRegister.ctorParameters=function(){return[]};var ScrollResolver=function(){function ScrollResolver(){this.lastScrollPosition=0}return ScrollResolver.prototype.shouldScroll=function(container,config,scrollingDown){var remaining,containerBreakpoint,distance=config.distance;scrollingDown?(remaining=container.totalToScroll-container.scrolledUntilNow,containerBreakpoint=container.height*distance.down+1):(remaining=container.scrolledUntilNow,containerBreakpoint=container.height*distance.up+1);var shouldScroll=remaining<=containerBreakpoint;return this.lastScrollPosition=container.scrolledUntilNow,shouldScroll},ScrollResolver.prototype.isScrollingDown=function(container){return this.lastScrollPosition<container.scrolledUntilNow},ScrollResolver.prototype.getScrollStats=function(container,config){var isScrollingDown=this.isScrollingDown(container);return{isScrollingDown:isScrollingDown,shouldScroll:this.shouldScroll(container,config,isScrollingDown)}},ScrollResolver}();ScrollResolver.decorators=[{type:_angular_core.Injectable}],ScrollResolver.ctorParameters=function(){return[]};var InfiniteScroll=function(){function InfiniteScroll(element,zone,positionResolverFactory,scrollRegister,scrollerResolver){this.element=element,this.zone=zone,this.positionResolverFactory=positionResolverFactory,this.scrollRegister=scrollRegister,this.scrollerResolver=scrollerResolver,this.scrolled=new _angular_core.EventEmitter,this.scrolledUp=new _angular_core.EventEmitter,this._distanceDown=2,this._distanceUp=1.5,this._throttle=300,this._disabled=!1,this._container=null,this.scrollWindow=!0,this._immediate=!1,this._horizontal=!1,this._alwaysCallback=!1,this.throttleType="throttle"}return Object.defineProperty(InfiniteScroll.prototype,"debounce",{set:function(value){this.throttleType=""===value||value?"debounce":"throttle"},enumerable:!0,configurable:!0}),InfiniteScroll.prototype.ngOnInit=function(){var _this=this;if("undefined"!=typeof window){var containerElement=this.resolveContainerElement(),positionResolver_1=this.positionResolverFactory.create({windowElement:containerElement,horizontal:this._horizontal}),options={container:positionResolver_1.container,throttleType:this.throttleType,throttleDuration:this._throttle,filterBefore:function(){return!_this._disabled},mergeMap:function(){return positionResolver_1.calculatePoints(_this.element)},scrollHandler:function(container){return _this.handleOnScroll(container)}};this.disposeScroller=this.scrollRegister.attachEvent(options)}},InfiniteScroll.prototype.handleOnScroll=function(container){var scrollResolverConfig={distance:{down:this._distanceDown,up:this._distanceUp}},scrollStats=this.scrollerResolver.getScrollStats(container,scrollResolverConfig);if(this.shouldTriggerEvents(scrollStats.shouldScroll)){var infiniteScrollEvent={currentScrollPosition:container.scrolledUntilNow};scrollStats.isScrollingDown?this.onScrollDown(infiniteScrollEvent):this.onScrollUp(infiniteScrollEvent)}},InfiniteScroll.prototype.shouldTriggerEvents=function(shouldScroll){return(this._alwaysCallback||shouldScroll)&&!this._disabled},InfiniteScroll.prototype.ngOnDestroy=function(){this.disposeScroller&&this.disposeScroller.unsubscribe()},InfiniteScroll.prototype.onScrollDown=function(data){var _this=this;void 0===data&&(data={currentScrollPosition:0}),this.zone.run(function(){return _this.scrolled.emit(data)})},InfiniteScroll.prototype.onScrollUp=function(data){var _this=this;void 0===data&&(data={currentScrollPosition:0}),this.zone.run(function(){return _this.scrolledUp.emit(data)})},InfiniteScroll.prototype.resolveContainerElement=function(){return this._container?"string"==typeof this._container?window.document.querySelector(this._container):this._container:this.scrollWindow?window:this.element},InfiniteScroll}();InfiniteScroll.decorators=[{type:_angular_core.Directive,args:[{selector:"[infiniteScroll],[infinite-scroll],[data-infinite-scroll]"}]}],InfiniteScroll.ctorParameters=function(){return[{type:_angular_core.ElementRef},{type:_angular_core.NgZone},{type:PositionResolverFactory},{type:ScrollRegister},{type:ScrollResolver}]},InfiniteScroll.propDecorators={scrolled:[{type:_angular_core.Output}],scrolledUp:[{type:_angular_core.Output}],_distanceDown:[{type:_angular_core.Input,args:["infiniteScrollDistance"]}],_distanceUp:[{type:_angular_core.Input,args:["infiniteScrollUpDistance"]}],_throttle:[{type:_angular_core.Input,args:["infiniteScrollThrottle"]}],_disabled:[{type:_angular_core.Input,args:["infiniteScrollDisabled"]}],_container:[{type:_angular_core.Input,args:["infiniteScrollContainer"]}],scrollWindow:[{type:_angular_core.Input,args:["scrollWindow"]}],_immediate:[{type:_angular_core.Input,args:["immediateCheck"]}],_horizontal:[{type:_angular_core.Input,args:["horizontal"]}],_alwaysCallback:[{type:_angular_core.Input,args:["alwaysCallback"]}],debounce:[{type:_angular_core.Input}]};var InfiniteScrollModule=function(){function InfiniteScrollModule(){}return InfiniteScrollModule}();InfiniteScrollModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[InfiniteScroll],exports:[InfiniteScroll],imports:[],providers:[AxisResolverFactory,PositionResolverFactory,ScrollRegister,ScrollResolver]}]}],InfiniteScrollModule.ctorParameters=function(){return[]},exports.InfiniteScrollModule=InfiniteScrollModule,exports.ɵa=InfiniteScroll,exports.ɵc=AxisResolverFactory,exports.ɵb=PositionResolverFactory,exports.ɵd=ScrollRegister,exports.ɵe=ScrollResolver,Object.defineProperty(exports,"__esModule",{value:!0})}); | ||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs/Observable"),require("rxjs/add/observable/fromEvent"),require("rxjs/add/observable/of"),require("rxjs/add/operator/sampleTime"),require("rxjs/add/operator/filter"),require("rxjs/add/operator/mergeMap")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/Observable","rxjs/add/observable/fromEvent","rxjs/add/observable/of","rxjs/add/operator/sampleTime","rxjs/add/operator/filter","rxjs/add/operator/mergeMap"],factory):factory((global.ng=global.ng||{},global.ng.ngxInfiniteScroll=global.ng.ngxInfiniteScroll||{}),global.ng.core,global.Rx)}(this,function(exports,_angular_core,rxjs_Observable){"use strict";var AxisResolverFactory=function(){function AxisResolverFactory(){}return AxisResolverFactory.prototype.create=function(vertical){return void 0===vertical&&(vertical=!0),new AxisResolver(vertical)},AxisResolverFactory}();AxisResolverFactory.decorators=[{type:_angular_core.Injectable}],AxisResolverFactory.ctorParameters=function(){return[]};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}(),PositionResolverFactory=function(){function PositionResolverFactory(axisResolver){this.axisResolver=axisResolver}return PositionResolverFactory.prototype.create=function(options){return new PositionResolver(this.axisResolver.create(!options.horizontal),options)},PositionResolverFactory}();PositionResolverFactory.decorators=[{type:_angular_core.Injectable}],PositionResolverFactory.ctorParameters=function(){return[{type:AxisResolverFactory}]};var PositionResolver=function(){function PositionResolver(axis,options){this.axis=axis,this.options=options,this.resolveContainer(this.options.windowElement),this.defineContainer(this.options.windowElement)}return PositionResolver.prototype.defineContainer=function(windowElement){return this.resolveContainer(windowElement)||!windowElement.nativeElement?this.container=windowElement:this.container=windowElement.nativeElement,this.container},PositionResolver.prototype.resolveContainer=function(windowElement){var isContainerWindow=Object.prototype.toString.call(windowElement).includes("Window");return this.isContainerWindow=isContainerWindow,isContainerWindow},PositionResolver.prototype.getDocumentElement=function(){return this.isContainerWindow?this.options.windowElement.document.documentElement:null},PositionResolver.prototype.calculatePoints=function(element){return this.isContainerWindow?this.calculatePointsForWindow(element):this.calculatePointsForElement(element)},PositionResolver.prototype.calculatePointsForWindow=function(element){var height=this.height(this.container);return{height:height,scrolledUntilNow:height+this.pageYOffset(this.getDocumentElement()),totalToScroll:this.offsetTop(element.nativeElement)+this.height(element.nativeElement)}},PositionResolver.prototype.calculatePointsForElement=function(element){var scrollTop=this.axis.scrollTopKey(),scrollHeight=this.axis.scrollHeightKey(),container=this.container,height=this.height(container),scrolledUntilNow=container[scrollTop],offsetTop=this.offsetTop(container);return void 0!==offsetTop&&offsetTop,{height:height,scrolledUntilNow:scrolledUntilNow,totalToScroll:container[scrollHeight]}},PositionResolver.prototype.height=function(elem){var offsetHeight=this.axis.offsetHeightKey(),clientHeight=this.axis.clientHeightKey();return isNaN(elem[offsetHeight])?this.getDocumentElement()[clientHeight]:elem[offsetHeight]},PositionResolver.prototype.offsetTop=function(elem){var top=this.axis.topKey();if(elem.getBoundingClientRect)return elem.getBoundingClientRect()[top]+this.pageYOffset(elem)},PositionResolver.prototype.pageYOffset=function(elem){var pageYOffset=this.axis.pageYOffsetKey(),scrollTop=this.axis.scrollTopKey(),offsetTop=this.axis.offsetTopKey();return isNaN(window[pageYOffset])?this.getDocumentElement()[scrollTop]:elem.ownerDocument?elem.ownerDocument.defaultView[pageYOffset]:elem[offsetTop]},PositionResolver}(),ScrollRegister=function(){function ScrollRegister(){}return ScrollRegister.prototype.attachEvent=function(options){return rxjs_Observable.Observable.fromEvent(options.container,"scroll").sampleTime(options.throttleDuration).filter(options.filterBefore).mergeMap(function(ev){return rxjs_Observable.Observable.of(options.mergeMap(ev))}).subscribe(options.scrollHandler)},ScrollRegister}();ScrollRegister.decorators=[{type:_angular_core.Injectable}],ScrollRegister.ctorParameters=function(){return[]};var ScrollResolver=function(){function ScrollResolver(){this.lastScrollPosition=0}return ScrollResolver.prototype.shouldScroll=function(container,config,scrollingDown){var remaining,containerBreakpoint,distance=config.distance;scrollingDown?(remaining=container.totalToScroll-container.scrolledUntilNow,containerBreakpoint=container.height*distance.down+1):(remaining=container.scrolledUntilNow,containerBreakpoint=container.height*distance.up+1);var shouldScroll=remaining<=containerBreakpoint;return this.lastScrollPosition=container.scrolledUntilNow,shouldScroll},ScrollResolver.prototype.isScrollingDown=function(container){return this.lastScrollPosition<container.scrolledUntilNow},ScrollResolver.prototype.getScrollStats=function(container,config){var isScrollingDown=this.isScrollingDown(container);return{isScrollingDown:isScrollingDown,shouldScroll:this.shouldScroll(container,config,isScrollingDown)}},ScrollResolver}();ScrollResolver.decorators=[{type:_angular_core.Injectable}],ScrollResolver.ctorParameters=function(){return[]};var InfiniteScrollDirective=function(){function InfiniteScrollDirective(element,zone,positionResolverFactory,scrollRegister,scrollerResolver){this.element=element,this.zone=zone,this.positionResolverFactory=positionResolverFactory,this.scrollRegister=scrollRegister,this.scrollerResolver=scrollerResolver,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}return InfiniteScrollDirective.prototype.ngOnInit=function(){var _this=this;if("undefined"!=typeof window){var containerElement=this.resolveContainerElement(),positionResolver_1=this.positionResolverFactory.create({horizontal:this.horizontal,windowElement:containerElement}),options={container:positionResolver_1.container,filterBefore:function(){return!_this.infiniteScrollDisabled},mergeMap:function(){return positionResolver_1.calculatePoints(_this.element)},scrollHandler:function(container){return _this.handleOnScroll(container)},throttleDuration:this.infiniteScrollThrottle};this.disposeScroller=this.scrollRegister.attachEvent(options)}},InfiniteScrollDirective.prototype.handleOnScroll=function(container){var scrollResolverConfig={distance:{down:this.infiniteScrollDistance,up:this.infiniteScrollUpDistance}},scrollStats=this.scrollerResolver.getScrollStats(container,scrollResolverConfig);if(this.shouldTriggerEvents(scrollStats.shouldScroll)){var infiniteScrollEvent={currentScrollPosition:container.scrolledUntilNow};scrollStats.isScrollingDown?this.onScrollDown(infiniteScrollEvent):this.onScrollUp(infiniteScrollEvent)}},InfiniteScrollDirective.prototype.shouldTriggerEvents=function(shouldScroll){return(this.alwaysCallback||shouldScroll)&&!this.infiniteScrollDisabled},InfiniteScrollDirective.prototype.ngOnDestroy=function(){this.disposeScroller&&this.disposeScroller.unsubscribe()},InfiniteScrollDirective.prototype.onScrollDown=function(data){var _this=this;void 0===data&&(data={currentScrollPosition:0}),this.zone.run(function(){return _this.scrolled.emit(data)})},InfiniteScrollDirective.prototype.onScrollUp=function(data){var _this=this;void 0===data&&(data={currentScrollPosition:0}),this.zone.run(function(){return _this.scrolledUp.emit(data)})},InfiniteScrollDirective.prototype.resolveContainerElement=function(){var selector=this.infiniteScrollContainer,hasWindow=window&&window.hasOwnProperty("document"),containerIsString=selector&&hasWindow&&"string"==typeof this.infiniteScrollContainer,container=containerIsString?window.document.querySelector(selector):selector;return selector||(container=this.scrollWindow?window:this.element),container},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},{type:PositionResolverFactory},{type:ScrollRegister},{type:ScrollResolver}]},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}]};var InfiniteScrollModule=function(){function InfiniteScrollModule(){}return InfiniteScrollModule}();InfiniteScrollModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[InfiniteScrollDirective],exports:[InfiniteScrollDirective],imports:[],providers:[AxisResolverFactory,PositionResolverFactory,ScrollRegister,ScrollResolver]}]}],InfiniteScrollModule.ctorParameters=function(){return[]},exports.InfiniteScrollModule=InfiniteScrollModule,exports.ɵa=InfiniteScrollDirective,exports.ɵc=AxisResolverFactory,exports.ɵb=PositionResolverFactory,exports.ɵd=ScrollRegister,exports.ɵe=ScrollResolver,Object.defineProperty(exports,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ngx-infinite-scroll.umd.min.js.map |
@@ -5,3 +5,3 @@ /** | ||
export * from './public_api'; | ||
export { InfiniteScroll as ɵa } from './src/modules/infinite-scroll.directive'; | ||
export { InfiniteScrollDirective as ɵa } from './src/modules/infinite-scroll.directive'; | ||
export { AxisResolverFactory as ɵc } from './src/services/axis-resolver'; | ||
@@ -8,0 +8,0 @@ export { PositionResolverFactory as ɵb } from './src/services/position-resolver'; |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":3,"metadata":{"InfiniteScrollModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ɵa"}],"exports":[{"__symbolic":"reference","name":"ɵa"}],"imports":[],"providers":[{"__symbolic":"reference","name":"ɵc"},{"__symbolic":"reference","name":"ɵb"},{"__symbolic":"reference","name":"ɵd"},{"__symbolic":"reference","name":"ɵe"}]}]}],"members":{}},"ɵa":{"__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"}}]}],"_distanceDown":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["infiniteScrollDistance"]}]}],"_distanceUp":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["infiniteScrollUpDistance"]}]}],"_throttle":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["infiniteScrollThrottle"]}]}],"_disabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["infiniteScrollDisabled"]}]}],"_container":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["infiniteScrollContainer"]}]}],"scrollWindow":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["scrollWindow"]}]}],"_immediate":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["immediateCheck"]}]}],"_horizontal":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["horizontal"]}]}],"_alwaysCallback":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["alwaysCallback"]}]}],"debounce":[{"__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"},{"__symbolic":"reference","name":"ɵb"},{"__symbolic":"reference","name":"ɵd"},{"__symbolic":"reference","name":"ɵe"}]}],"ngOnInit":[{"__symbolic":"method"}],"handleOnScroll":[{"__symbolic":"method"}],"shouldTriggerEvents":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onScrollDown":[{"__symbolic":"method"}],"onScrollUp":[{"__symbolic":"method"}],"resolveContainerElement":[{"__symbolic":"method"}]}},"ɵb":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"ɵc"}]}],"create":[{"__symbolic":"method"}]}},"ɵc":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"create":[{"__symbolic":"method"}]}},"ɵd":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"attachEvent":[{"__symbolic":"method"}]}},"ɵe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"shouldScroll":[{"__symbolic":"method"}],"isScrollingDown":[{"__symbolic":"method"}],"getScrollStats":[{"__symbolic":"method"}]}}},"origins":{"InfiniteScrollModule":"./src/modules/ngx-infinite-scroll.module","ɵa":"./src/modules/infinite-scroll.directive","ɵb":"./src/services/position-resolver","ɵc":"./src/services/axis-resolver","ɵd":"./src/services/scroll-register","ɵe":"./src/services/scroll-resolver"},"importAs":"ngx-infinite-scroll"} | ||
{"__symbolic":"module","version":3,"metadata":{"InfiniteScrollModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ɵa"}],"exports":[{"__symbolic":"reference","name":"ɵa"}],"imports":[],"providers":[{"__symbolic":"reference","name":"ɵc"},{"__symbolic":"reference","name":"ɵb"},{"__symbolic":"reference","name":"ɵd"},{"__symbolic":"reference","name":"ɵe"}]}]}],"members":{}},"ɵa":{"__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"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"NgZone"},{"__symbolic":"reference","name":"ɵb"},{"__symbolic":"reference","name":"ɵd"},{"__symbolic":"reference","name":"ɵe"}]}],"ngOnInit":[{"__symbolic":"method"}],"handleOnScroll":[{"__symbolic":"method"}],"shouldTriggerEvents":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onScrollDown":[{"__symbolic":"method"}],"onScrollUp":[{"__symbolic":"method"}],"resolveContainerElement":[{"__symbolic":"method"}]}},"ɵb":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"ɵc"}]}],"create":[{"__symbolic":"method"}]}},"ɵc":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"create":[{"__symbolic":"method"}]}},"ɵd":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"attachEvent":[{"__symbolic":"method"}]}},"ɵe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"shouldScroll":[{"__symbolic":"method"}],"isScrollingDown":[{"__symbolic":"method"}],"getScrollStats":[{"__symbolic":"method"}]}}},"origins":{"InfiniteScrollModule":"./src/modules/ngx-infinite-scroll.module","ɵa":"./src/modules/infinite-scroll.directive","ɵb":"./src/services/position-resolver","ɵc":"./src/services/axis-resolver","ɵd":"./src/services/scroll-register","ɵe":"./src/services/scroll-resolver"},"importAs":"ngx-infinite-scroll"} |
@@ -5,5 +5,5 @@ import { Directive, ElementRef, EventEmitter, Injectable, Input, NgModule, NgZone, Output } from '@angular/core'; | ||
import 'rxjs/add/observable/of'; | ||
import 'rxjs/add/operator/sampleTime'; | ||
import 'rxjs/add/operator/filter'; | ||
import 'rxjs/add/operator/mergeMap'; | ||
import 'rxjs/add/operator/sampleTime'; | ||
var AxisResolverFactory = (function () { | ||
@@ -298,3 +298,3 @@ function AxisResolverFactory() { | ||
ScrollResolver.ctorParameters = function () { return []; }; | ||
var InfiniteScroll = (function () { | ||
var InfiniteScrollDirective = (function () { | ||
/** | ||
@@ -307,3 +307,3 @@ * @param {?} element | ||
*/ | ||
function InfiniteScroll(element, zone, positionResolverFactory, scrollRegister, scrollerResolver) { | ||
function InfiniteScrollDirective(element, zone, positionResolverFactory, scrollRegister, scrollerResolver) { | ||
this.element = element; | ||
@@ -316,28 +316,16 @@ this.zone = zone; | ||
this.scrolledUp = new EventEmitter(); | ||
this._distanceDown = 2; | ||
this._distanceUp = 1.5; | ||
this._throttle = 300; | ||
this._disabled = false; | ||
this._container = null; | ||
this.infiniteScrollDistance = 2; | ||
this.infiniteScrollUpDistance = 1.5; | ||
this.infiniteScrollThrottle = 300; | ||
this.infiniteScrollDisabled = false; | ||
this.infiniteScrollContainer = null; | ||
this.scrollWindow = true; | ||
this._immediate = false; | ||
this._horizontal = false; | ||
this._alwaysCallback = false; | ||
this.throttleType = 'throttle'; | ||
this.immediateCheck = false; | ||
this.horizontal = false; | ||
this.alwaysCallback = false; | ||
} | ||
Object.defineProperty(InfiniteScroll.prototype, "debounce", { | ||
/** | ||
* @param {?} value | ||
* @return {?} | ||
*/ | ||
set: function (value) { | ||
this.throttleType = value === '' || !!value ? 'debounce' : 'throttle'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* @return {?} | ||
*/ | ||
InfiniteScroll.prototype.ngOnInit = function () { | ||
InfiniteScrollDirective.prototype.ngOnInit = function () { | ||
var _this = this; | ||
@@ -347,12 +335,11 @@ if (typeof window !== 'undefined') { | ||
var /** @type {?} */ positionResolver_1 = this.positionResolverFactory.create({ | ||
windowElement: containerElement, | ||
horizontal: this._horizontal | ||
horizontal: this.horizontal, | ||
windowElement: containerElement | ||
}); | ||
var /** @type {?} */ options = { | ||
container: positionResolver_1.container, | ||
throttleType: this.throttleType, | ||
throttleDuration: this._throttle, | ||
filterBefore: function () { return !_this._disabled; }, | ||
filterBefore: function () { return !_this.infiniteScrollDisabled; }, | ||
mergeMap: function () { return positionResolver_1.calculatePoints(_this.element); }, | ||
scrollHandler: function (container) { return _this.handleOnScroll(container); } | ||
scrollHandler: function (container) { return _this.handleOnScroll(container); }, | ||
throttleDuration: this.infiniteScrollThrottle | ||
}; | ||
@@ -366,7 +353,7 @@ this.disposeScroller = this.scrollRegister.attachEvent(options); | ||
*/ | ||
InfiniteScroll.prototype.handleOnScroll = function (container) { | ||
InfiniteScrollDirective.prototype.handleOnScroll = function (container) { | ||
var /** @type {?} */ scrollResolverConfig = { | ||
distance: { | ||
down: this._distanceDown, | ||
up: this._distanceUp | ||
down: this.infiniteScrollDistance, | ||
up: this.infiniteScrollUpDistance | ||
} | ||
@@ -391,4 +378,4 @@ }; | ||
*/ | ||
InfiniteScroll.prototype.shouldTriggerEvents = function (shouldScroll) { | ||
return (this._alwaysCallback || shouldScroll) && !this._disabled; | ||
InfiniteScrollDirective.prototype.shouldTriggerEvents = function (shouldScroll) { | ||
return (this.alwaysCallback || shouldScroll) && !this.infiniteScrollDisabled; | ||
}; | ||
@@ -398,3 +385,3 @@ /** | ||
*/ | ||
InfiniteScroll.prototype.ngOnDestroy = function () { | ||
InfiniteScrollDirective.prototype.ngOnDestroy = function () { | ||
if (this.disposeScroller) { | ||
@@ -408,3 +395,3 @@ this.disposeScroller.unsubscribe(); | ||
*/ | ||
InfiniteScroll.prototype.onScrollDown = function (data) { | ||
InfiniteScrollDirective.prototype.onScrollDown = function (data) { | ||
var _this = this; | ||
@@ -418,3 +405,3 @@ if (data === void 0) { data = { currentScrollPosition: 0 }; } | ||
*/ | ||
InfiniteScroll.prototype.onScrollUp = function (data) { | ||
InfiniteScrollDirective.prototype.onScrollUp = function (data) { | ||
var _this = this; | ||
@@ -427,15 +414,19 @@ if (data === void 0) { data = { currentScrollPosition: 0 }; } | ||
*/ | ||
InfiniteScroll.prototype.resolveContainerElement = function () { | ||
if (this._container) { | ||
return typeof (this._container) === 'string' ? window.document.querySelector(this._container) : this._container; | ||
InfiniteScrollDirective.prototype.resolveContainerElement = function () { | ||
var /** @type {?} */ selector = this.infiniteScrollContainer; | ||
var /** @type {?} */ hasWindow = window && window.hasOwnProperty('document'); | ||
var /** @type {?} */ containerIsString = selector && hasWindow && typeof (this.infiniteScrollContainer) === 'string'; | ||
var /** @type {?} */ container = containerIsString | ||
? window.document.querySelector(selector) | ||
: selector; | ||
if (!selector) { | ||
container = this.scrollWindow ? window : this.element; | ||
} | ||
else { | ||
return this.scrollWindow ? window : this.element; | ||
} | ||
return container; | ||
}; | ||
return InfiniteScroll; | ||
return InfiniteScrollDirective; | ||
}()); | ||
InfiniteScroll.decorators = [ | ||
InfiniteScrollDirective.decorators = [ | ||
{ type: Directive, args: [{ | ||
selector: '[infiniteScroll],[infinite-scroll],[data-infinite-scroll]' | ||
selector: '[infiniteScroll], [infinite-scroll], [data-infinite-scroll]' | ||
},] }, | ||
@@ -446,3 +437,3 @@ ]; | ||
*/ | ||
InfiniteScroll.ctorParameters = function () { return [ | ||
InfiniteScrollDirective.ctorParameters = function () { return [ | ||
{ type: ElementRef, }, | ||
@@ -454,15 +445,14 @@ { type: NgZone, }, | ||
]; }; | ||
InfiniteScroll.propDecorators = { | ||
InfiniteScrollDirective.propDecorators = { | ||
'scrolled': [{ type: Output },], | ||
'scrolledUp': [{ type: Output },], | ||
'_distanceDown': [{ type: Input, args: ['infiniteScrollDistance',] },], | ||
'_distanceUp': [{ type: Input, args: ['infiniteScrollUpDistance',] },], | ||
'_throttle': [{ type: Input, args: ['infiniteScrollThrottle',] },], | ||
'_disabled': [{ type: Input, args: ['infiniteScrollDisabled',] },], | ||
'_container': [{ type: Input, args: ['infiniteScrollContainer',] },], | ||
'scrollWindow': [{ type: Input, args: ['scrollWindow',] },], | ||
'_immediate': [{ type: Input, args: ['immediateCheck',] },], | ||
'_horizontal': [{ type: Input, args: ['horizontal',] },], | ||
'_alwaysCallback': [{ type: Input, args: ['alwaysCallback',] },], | ||
'debounce': [{ type: Input },], | ||
'infiniteScrollDistance': [{ type: Input },], | ||
'infiniteScrollUpDistance': [{ type: Input },], | ||
'infiniteScrollThrottle': [{ type: Input },], | ||
'infiniteScrollDisabled': [{ type: Input },], | ||
'infiniteScrollContainer': [{ type: Input },], | ||
'scrollWindow': [{ type: Input },], | ||
'immediateCheck': [{ type: Input },], | ||
'horizontal': [{ type: Input },], | ||
'alwaysCallback': [{ type: Input },], | ||
}; | ||
@@ -476,4 +466,4 @@ var InfiniteScrollModule = (function () { | ||
{ type: NgModule, args: [{ | ||
declarations: [InfiniteScroll], | ||
exports: [InfiniteScroll], | ||
declarations: [InfiniteScrollDirective], | ||
exports: [InfiniteScrollDirective], | ||
imports: [], | ||
@@ -505,3 +495,3 @@ providers: [ | ||
*/ | ||
export { InfiniteScrollModule, InfiniteScroll as ɵa, AxisResolverFactory as ɵc, PositionResolverFactory as ɵb, ScrollRegister as ɵd, ScrollResolver as ɵe }; | ||
export { InfiniteScrollModule, InfiniteScrollDirective as ɵa, AxisResolverFactory as ɵc, PositionResolverFactory as ɵb, ScrollRegister as ɵd, ScrollResolver as ɵe }; | ||
//# sourceMappingURL=ngx-infinite-scroll.es5.js.map |
@@ -5,5 +5,5 @@ import { Directive, ElementRef, EventEmitter, Injectable, Input, NgModule, NgZone, Output } from '@angular/core'; | ||
import 'rxjs/add/observable/of'; | ||
import 'rxjs/add/operator/sampleTime'; | ||
import 'rxjs/add/operator/filter'; | ||
import 'rxjs/add/operator/mergeMap'; | ||
import 'rxjs/add/operator/sampleTime'; | ||
@@ -292,3 +292,3 @@ class AxisResolverFactory { | ||
class InfiniteScroll { | ||
class InfiniteScrollDirective { | ||
/** | ||
@@ -309,23 +309,15 @@ * @param {?} element | ||
this.scrolledUp = new EventEmitter(); | ||
this._distanceDown = 2; | ||
this._distanceUp = 1.5; | ||
this._throttle = 300; | ||
this._disabled = false; | ||
this._container = null; | ||
this.infiniteScrollDistance = 2; | ||
this.infiniteScrollUpDistance = 1.5; | ||
this.infiniteScrollThrottle = 300; | ||
this.infiniteScrollDisabled = false; | ||
this.infiniteScrollContainer = null; | ||
this.scrollWindow = true; | ||
this._immediate = false; | ||
this._horizontal = false; | ||
this._alwaysCallback = false; | ||
this.throttleType = 'throttle'; | ||
this.immediateCheck = false; | ||
this.horizontal = false; | ||
this.alwaysCallback = false; | ||
} | ||
/** | ||
* @param {?} value | ||
* @return {?} | ||
*/ | ||
set debounce(value) { | ||
this.throttleType = value === '' || !!value ? 'debounce' : 'throttle'; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
ngOnInit() { | ||
@@ -335,12 +327,11 @@ if (typeof window !== 'undefined') { | ||
const /** @type {?} */ positionResolver = this.positionResolverFactory.create({ | ||
windowElement: containerElement, | ||
horizontal: this._horizontal | ||
horizontal: this.horizontal, | ||
windowElement: containerElement | ||
}); | ||
const /** @type {?} */ options = { | ||
container: positionResolver.container, | ||
throttleType: this.throttleType, | ||
throttleDuration: this._throttle, | ||
filterBefore: () => !this._disabled, | ||
filterBefore: () => !this.infiniteScrollDisabled, | ||
mergeMap: () => positionResolver.calculatePoints(this.element), | ||
scrollHandler: (container) => this.handleOnScroll(container) | ||
scrollHandler: (container) => this.handleOnScroll(container), | ||
throttleDuration: this.infiniteScrollThrottle | ||
}; | ||
@@ -357,4 +348,4 @@ this.disposeScroller = this.scrollRegister.attachEvent(options); | ||
distance: { | ||
down: this._distanceDown, | ||
up: this._distanceUp | ||
down: this.infiniteScrollDistance, | ||
up: this.infiniteScrollUpDistance | ||
} | ||
@@ -380,3 +371,3 @@ }; | ||
shouldTriggerEvents(shouldScroll) { | ||
return (this._alwaysCallback || shouldScroll) && !this._disabled; | ||
return (this.alwaysCallback || shouldScroll) && !this.infiniteScrollDisabled; | ||
} | ||
@@ -409,13 +400,17 @@ /** | ||
resolveContainerElement() { | ||
if (this._container) { | ||
return typeof (this._container) === 'string' ? window.document.querySelector(this._container) : this._container; | ||
const /** @type {?} */ selector = this.infiniteScrollContainer; | ||
const /** @type {?} */ hasWindow = window && window.hasOwnProperty('document'); | ||
const /** @type {?} */ containerIsString = selector && hasWindow && typeof (this.infiniteScrollContainer) === 'string'; | ||
let /** @type {?} */ container = containerIsString | ||
? window.document.querySelector(selector) | ||
: selector; | ||
if (!selector) { | ||
container = this.scrollWindow ? window : this.element; | ||
} | ||
else { | ||
return this.scrollWindow ? window : this.element; | ||
} | ||
return container; | ||
} | ||
} | ||
InfiniteScroll.decorators = [ | ||
InfiniteScrollDirective.decorators = [ | ||
{ type: Directive, args: [{ | ||
selector: '[infiniteScroll],[infinite-scroll],[data-infinite-scroll]' | ||
selector: '[infiniteScroll], [infinite-scroll], [data-infinite-scroll]' | ||
},] }, | ||
@@ -426,3 +421,3 @@ ]; | ||
*/ | ||
InfiniteScroll.ctorParameters = () => [ | ||
InfiniteScrollDirective.ctorParameters = () => [ | ||
{ type: ElementRef, }, | ||
@@ -434,15 +429,14 @@ { type: NgZone, }, | ||
]; | ||
InfiniteScroll.propDecorators = { | ||
InfiniteScrollDirective.propDecorators = { | ||
'scrolled': [{ type: Output },], | ||
'scrolledUp': [{ type: Output },], | ||
'_distanceDown': [{ type: Input, args: ['infiniteScrollDistance',] },], | ||
'_distanceUp': [{ type: Input, args: ['infiniteScrollUpDistance',] },], | ||
'_throttle': [{ type: Input, args: ['infiniteScrollThrottle',] },], | ||
'_disabled': [{ type: Input, args: ['infiniteScrollDisabled',] },], | ||
'_container': [{ type: Input, args: ['infiniteScrollContainer',] },], | ||
'scrollWindow': [{ type: Input, args: ['scrollWindow',] },], | ||
'_immediate': [{ type: Input, args: ['immediateCheck',] },], | ||
'_horizontal': [{ type: Input, args: ['horizontal',] },], | ||
'_alwaysCallback': [{ type: Input, args: ['alwaysCallback',] },], | ||
'debounce': [{ type: Input },], | ||
'infiniteScrollDistance': [{ type: Input },], | ||
'infiniteScrollUpDistance': [{ type: Input },], | ||
'infiniteScrollThrottle': [{ type: Input },], | ||
'infiniteScrollDisabled': [{ type: Input },], | ||
'infiniteScrollContainer': [{ type: Input },], | ||
'scrollWindow': [{ type: Input },], | ||
'immediateCheck': [{ type: Input },], | ||
'horizontal': [{ type: Input },], | ||
'alwaysCallback': [{ type: Input },], | ||
}; | ||
@@ -454,4 +448,4 @@ | ||
{ type: NgModule, args: [{ | ||
declarations: [InfiniteScroll], | ||
exports: [InfiniteScroll], | ||
declarations: [InfiniteScrollDirective], | ||
exports: [InfiniteScrollDirective], | ||
imports: [], | ||
@@ -486,3 +480,3 @@ providers: [ | ||
export { InfiniteScrollModule, InfiniteScroll as ɵa, AxisResolverFactory as ɵc, PositionResolverFactory as ɵb, ScrollRegister as ɵd, ScrollResolver as ɵe }; | ||
export { InfiniteScrollModule, InfiniteScrollDirective as ɵa, AxisResolverFactory as ɵc, PositionResolverFactory as ɵb, ScrollRegister as ɵd, ScrollResolver as ɵe }; | ||
//# sourceMappingURL=ngx-infinite-scroll.js.map |
{ | ||
"name": "ngx-infinite-scroll", | ||
"version": "0.4.3-1", | ||
"version": "0.4.3", | ||
"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", |
@@ -6,3 +6,3 @@ import { InfiniteScrollEvent, PositionStats } from '../models'; | ||
import { ScrollResolver } from '../services/scroll-resolver'; | ||
export declare class InfiniteScroll implements OnDestroy, OnInit { | ||
export declare class InfiniteScrollDirective implements OnDestroy, OnInit { | ||
private element; | ||
@@ -15,13 +15,11 @@ private zone; | ||
scrolledUp: EventEmitter<InfiniteScrollEvent>; | ||
_distanceDown: number; | ||
_distanceUp: number; | ||
_throttle: number; | ||
_disabled: boolean; | ||
_container: any; | ||
infiniteScrollDistance: number; | ||
infiniteScrollUpDistance: number; | ||
infiniteScrollThrottle: number; | ||
infiniteScrollDisabled: boolean; | ||
infiniteScrollContainer: any; | ||
scrollWindow: boolean; | ||
_immediate: boolean; | ||
_horizontal: boolean; | ||
_alwaysCallback: boolean; | ||
debounce: string | boolean; | ||
private throttleType; | ||
immediateCheck: boolean; | ||
horizontal: boolean; | ||
alwaysCallback: boolean; | ||
private disposeScroller; | ||
@@ -28,0 +26,0 @@ constructor(element: ElementRef, zone: NgZone, positionResolverFactory: PositionResolverFactory, scrollRegister: ScrollRegister, scrollerResolver: ScrollResolver); |
@@ -5,8 +5,7 @@ import { ContainerRef } from '../models'; | ||
import 'rxjs/add/observable/of'; | ||
import 'rxjs/add/operator/sampleTime'; | ||
import 'rxjs/add/operator/filter'; | ||
import 'rxjs/add/operator/mergeMap'; | ||
import 'rxjs/add/operator/sampleTime'; | ||
export interface ScrollRegisterConfig { | ||
container: ContainerRef; | ||
throttleType: string; | ||
throttleDuration: number; | ||
@@ -13,0 +12,0 @@ filterBefore: () => 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
198837
1616