Added DelayedAction class to use to handle stopping scrolling
Этот коммит содержится в:
@@ -7,6 +7,7 @@ import * as EventHelpers from '../dispatcher/event_helpers.jsx';
|
|||||||
import * as Utils from '../utils/utils.jsx';
|
import * as Utils from '../utils/utils.jsx';
|
||||||
import Post from './post.jsx';
|
import Post from './post.jsx';
|
||||||
import Constants from '../utils/constants.jsx';
|
import Constants from '../utils/constants.jsx';
|
||||||
|
import DelayedAction from '../utils/delayed_action.jsx';
|
||||||
const Preferences = Constants.Preferences;
|
const Preferences = Constants.Preferences;
|
||||||
|
|
||||||
export default class PostsView extends React.Component {
|
export default class PostsView extends React.Component {
|
||||||
@@ -15,6 +16,7 @@ export default class PostsView extends React.Component {
|
|||||||
|
|
||||||
this.updateState = this.updateState.bind(this);
|
this.updateState = this.updateState.bind(this);
|
||||||
this.handleScroll = this.handleScroll.bind(this);
|
this.handleScroll = this.handleScroll.bind(this);
|
||||||
|
this.handleScrollStop = this.handleScrollStop.bind(this);
|
||||||
this.isAtBottom = this.isAtBottom.bind(this);
|
this.isAtBottom = this.isAtBottom.bind(this);
|
||||||
this.loadMorePostsTop = this.loadMorePostsTop.bind(this);
|
this.loadMorePostsTop = this.loadMorePostsTop.bind(this);
|
||||||
this.loadMorePostsBottom = this.loadMorePostsBottom.bind(this);
|
this.loadMorePostsBottom = this.loadMorePostsBottom.bind(this);
|
||||||
@@ -26,9 +28,11 @@ export default class PostsView extends React.Component {
|
|||||||
this.wasAtBottom = true;
|
this.wasAtBottom = true;
|
||||||
this.scrollHeight = 0;
|
this.scrollHeight = 0;
|
||||||
|
|
||||||
|
this.scrollStopAction = new DelayedAction(this.handleScrollStop);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false'),
|
displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false'),
|
||||||
isScrolling: true, // TODO change this once we start detecting scrolling
|
isScrolling: false,
|
||||||
topPostId: null
|
topPostId: null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -75,6 +79,19 @@ export default class PostsView extends React.Component {
|
|||||||
this.prevOffsetTop = this.jumpToPostNode.offsetTop;
|
this.prevOffsetTop = this.jumpToPostNode.offsetTop;
|
||||||
|
|
||||||
this.updateFloatingTimestamp();
|
this.updateFloatingTimestamp();
|
||||||
|
|
||||||
|
if (!this.state.isScrolling) {
|
||||||
|
this.setState({
|
||||||
|
isScrolling: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.scrollStopAction.fireAfter(1000);
|
||||||
|
}
|
||||||
|
handleScrollStop() {
|
||||||
|
this.setState({
|
||||||
|
isScrolling: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
updateFloatingTimestamp() {
|
updateFloatingTimestamp() {
|
||||||
if (this.props.postList) {
|
if (this.props.postList) {
|
||||||
|
|||||||
27
web/react/utils/delayed_action.jsx
Обычный файл
27
web/react/utils/delayed_action.jsx
Обычный файл
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
export default class DelayedAction {
|
||||||
|
constructor(action) {
|
||||||
|
this.action = action;
|
||||||
|
|
||||||
|
this.timer = -1;
|
||||||
|
|
||||||
|
// bind fire since it doesn't get passed the correct this value with setTimeout
|
||||||
|
this.fire = this.fire.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
fire() {
|
||||||
|
this.action();
|
||||||
|
|
||||||
|
this.timer = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fireAfter(timeout) {
|
||||||
|
if (this.timer >= 0) {
|
||||||
|
window.clearTimeout(this.timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.timer = window.setTimeout(this.fire, timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -262,7 +262,7 @@ body.ios {
|
|||||||
line-height: 25px;
|
line-height: 25px;
|
||||||
margin-left: -60px;
|
margin-left: -60px;
|
||||||
-webkit-font-smoothing: initial;
|
-webkit-font-smoothing: initial;
|
||||||
@include single-transition(all, 0.3s, ease, 1.0s);
|
@include single-transition(all, 0.3s, ease);
|
||||||
@include translateY(-45px);
|
@include translateY(-45px);
|
||||||
@include opacity(0);
|
@include opacity(0);
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user