diff options
Diffstat (limited to 'client/components/sidebar/infiniteScrolling.js')
-rw-r--r-- | client/components/sidebar/infiniteScrolling.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/client/components/sidebar/infiniteScrolling.js b/client/components/sidebar/infiniteScrolling.js new file mode 100644 index 00000000..df3b8901 --- /dev/null +++ b/client/components/sidebar/infiniteScrolling.js @@ -0,0 +1,37 @@ +var peakAnticipation = 200; + +Mixins.InfiniteScrolling = BlazeComponent.extendComponent({ + onCreated: function() { + this._nextPeak = Infinity; + }, + + setNextPeak: function(v) { + this._nextPeak = v; + }, + + getNextPeak: function() { + return this._nextPeak; + }, + + resetNextPeak: function() { + this._nextPeak = Infinity; + }, + + // To be overwritten by consumers of this mixin + reachNextPeak: function() { + + }, + + events: function() { + return [{ + scroll: function(evt) { + var domElement = evt.currentTarget; + var altitude = domElement.scrollTop + domElement.offsetHeight; + altitude += peakAnticipation; + if (altitude >= this.callFirstWith(null, 'getNextPeak')) { + this.callFirstWith(null, 'reachNextPeak'); + } + } + }]; + } +}); |