aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/js/utils.js')
-rw-r--r--web/src/js/utils.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/web/src/js/utils.js b/web/src/js/utils.js
new file mode 100644
index 00000000..39ad92fb
--- /dev/null
+++ b/web/src/js/utils.js
@@ -0,0 +1,13 @@
+// http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html (also contains inverse example)
+var AutoScrollMixin = {
+ componentWillUpdate: function () {
+ var node = this.getDOMNode();
+ this._shouldScrollBottom = node.scrollTop + node.clientHeight === node.scrollHeight;
+ },
+ componentDidUpdate: function () {
+ if (this._shouldScrollBottom) {
+ var node = this.getDOMNode();
+ node.scrollTop = node.scrollHeight;
+ }
+ },
+};