about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features/notifications/index.jsx
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-01-26 04:30:40 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-01-26 04:30:40 +0100
commit905c82917959a5afe24cb85c62c0b0ba13f0da8b (patch)
treea22df9a8737250f97a6024943af3445a163917b3 /app/assets/javascripts/components/features/notifications/index.jsx
parent57f7cf834921d49f28f346571e0e6fb596ccd6f8 (diff)
Improve infinite scroll on notifications
Diffstat (limited to 'app/assets/javascripts/components/features/notifications/index.jsx')
-rw-r--r--app/assets/javascripts/components/features/notifications/index.jsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/assets/javascripts/components/features/notifications/index.jsx b/app/assets/javascripts/components/features/notifications/index.jsx
index 366d8f5e9..b4593aaff 100644
--- a/app/assets/javascripts/components/features/notifications/index.jsx
+++ b/app/assets/javascripts/components/features/notifications/index.jsx
@@ -20,7 +20,8 @@ const getNotifications = createSelector([
 ], (excludedTypes, notifications) => notifications.filterNot(item => excludedTypes.includes(item.get('type'))));
 
 const mapStateToProps = state => ({
-  notifications: getNotifications(state)
+  notifications: getNotifications(state),
+  isLoading: state.getIn(['notifications', 'isLoading'], true)
 });
 
 const Notifications = React.createClass({
@@ -29,7 +30,8 @@ const Notifications = React.createClass({
     notifications: ImmutablePropTypes.list.isRequired,
     dispatch: React.PropTypes.func.isRequired,
     trackScroll: React.PropTypes.bool,
-    intl: React.PropTypes.object.isRequired
+    intl: React.PropTypes.object.isRequired,
+    isLoading: React.PropTypes.bool
   },
 
   getDefaultProps () {
@@ -42,8 +44,9 @@ const Notifications = React.createClass({
 
   handleScroll (e) {
     const { scrollTop, scrollHeight, clientHeight } = e.target;
+    const offset = scrollHeight - scrollTop - clientHeight;
 
-    if (scrollTop === scrollHeight - clientHeight) {
+    if (250 > offset && !this.props.isLoading) {
       this.props.dispatch(expandNotifications());
     }
   },