summaryrefslogtreecommitdiffstats
path: root/client/components/mixins
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/mixins')
-rw-r--r--client/components/mixins/infiniteScrolling.js37
-rw-r--r--client/components/mixins/perfectScrollbar.js6
-rw-r--r--client/components/mixins/perfectScrollbar.styl2
3 files changed, 45 insertions, 0 deletions
diff --git a/client/components/mixins/infiniteScrolling.js b/client/components/mixins/infiniteScrolling.js
new file mode 100644
index 00000000..df3b8901
--- /dev/null
+++ b/client/components/mixins/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');
+ }
+ }
+ }];
+ }
+});
diff --git a/client/components/mixins/perfectScrollbar.js b/client/components/mixins/perfectScrollbar.js
new file mode 100644
index 00000000..06e8aedd
--- /dev/null
+++ b/client/components/mixins/perfectScrollbar.js
@@ -0,0 +1,6 @@
+Mixins.PerfectScrollbar = BlazeComponent.extendComponent({
+ onRendered: function() {
+ var component = this.mixinParent();
+ Ps.initialize(component.find('.js-perfect-scrollbar'));
+ }
+});
diff --git a/client/components/mixins/perfectScrollbar.styl b/client/components/mixins/perfectScrollbar.styl
new file mode 100644
index 00000000..c8267668
--- /dev/null
+++ b/client/components/mixins/perfectScrollbar.styl
@@ -0,0 +1,2 @@
+.ps-container
+ position: relative