From 1c0496e051d8b1af297138732475b1689ada5eb8 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 10 Mar 2016 21:40:07 +0800 Subject: [web] VirtualScroll and AutoScroll helper --- web/src/js/components/common.js | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'web/src/js/components/common.js') diff --git a/web/src/js/components/common.js b/web/src/js/components/common.js index 23e0a434..ad97ab38 100644 --- a/web/src/js/components/common.js +++ b/web/src/js/components/common.js @@ -2,34 +2,6 @@ import React from "react" import ReactDOM from "react-dom" import _ from "lodash" -// http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html (also contains inverse example) -export var AutoScrollMixin = { - componentWillUpdate: function () { - var node = ReactDOM.findDOMNode(this); - this._shouldScrollBottom = ( - node.scrollTop !== 0 && - node.scrollTop + node.clientHeight === node.scrollHeight - ); - }, - componentDidUpdate: function () { - if (this._shouldScrollBottom) { - var node = ReactDOM.findDOMNode(this); - node.scrollTop = node.scrollHeight; - } - } -}; - - -export var StickyHeadMixin = { - adjustHead: function () { - // Abusing CSS transforms to set the element - // referenced as head into some kind of position:sticky. - var head = ReactDOM.findDOMNode(this.refs.head); - head.style.transform = "translate(0," + ReactDOM.findDOMNode(this).scrollTop + "px)"; - } -}; - - export var Router = { contextTypes: { location: React.PropTypes.object, -- cgit v1.2.3