From ca8d57c4dbfe839db28b583caa7d599c0cfc023a Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 23 Jun 2017 12:09:56 -0400 Subject: PLT-6890 Fix various scrolling issues (#6727) * Fix various scrolling issues * Move reaction scrolling to reaction list * Handle scrolling when RHS opens * Only run scroll update code when posts change --- webapp/utils/constants.jsx | 2 +- webapp/utils/event_types.jsx | 8 ++++++++ webapp/utils/global_event_emitter.jsx | 27 +++++++++++++++++++++++++++ webapp/utils/markdown.jsx | 7 ++++--- 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 webapp/utils/event_types.jsx create mode 100644 webapp/utils/global_event_emitter.jsx (limited to 'webapp/utils') diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 9b18b52f9..9dbc43f60 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import keyMirror from 'key-mirror/keyMirror.js'; +import keyMirror from 'key-mirror'; import audioIcon from 'images/icons/audio.png'; import videoIcon from 'images/icons/video.png'; diff --git a/webapp/utils/event_types.jsx b/webapp/utils/event_types.jsx new file mode 100644 index 000000000..1d43f4290 --- /dev/null +++ b/webapp/utils/event_types.jsx @@ -0,0 +1,8 @@ +// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import keyMirror from 'key-mirror'; + +export default keyMirror({ + POST_LIST_SCROLL_CHANGE: null +}); diff --git a/webapp/utils/global_event_emitter.jsx b/webapp/utils/global_event_emitter.jsx new file mode 100644 index 000000000..0d231d2a2 --- /dev/null +++ b/webapp/utils/global_event_emitter.jsx @@ -0,0 +1,27 @@ +// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import AppDispatcher from 'dispatcher/app_dispatcher.jsx'; +import EventEmitter from 'events'; + +import EventTypes from 'utils/event_types.jsx'; + +class GlobalEventEmitterClass extends EventEmitter { + constructor() { + super(); + this.dispatchToken = AppDispatcher.register(this.handleEventPayload); + } + + handleEventPayload = (payload) => { + const {type, value, ...args} = payload.action; //eslint-disable-line no-use-before-define + + switch (type) { + case EventTypes.POST_LIST_SCROLL_CHANGE: + this.emit(type, value, args); + break; + } + } +} + +const GlobalEventEmitter = new GlobalEventEmitterClass(); +export default GlobalEventEmitter; diff --git a/webapp/utils/markdown.jsx b/webapp/utils/markdown.jsx index f47c45d10..60ccbd246 100644 --- a/webapp/utils/markdown.jsx +++ b/webapp/utils/markdown.jsx @@ -4,11 +4,11 @@ import * as TextFormatting from './text_formatting.jsx'; import * as SyntaxHighlighting from './syntax_highlighting.jsx'; +import {postListScrollChange} from 'actions/global_actions.jsx'; + import marked from 'marked'; import katex from 'katex'; -import ScrollStore from 'stores/scroll_store.jsx'; - function markdownImageLoaded(image) { if (image.hasAttribute('height') && image.attributes.height.value !== 'auto') { const maxHeight = parseInt(global.getComputedStyle(image).maxHeight, 10); @@ -22,7 +22,8 @@ function markdownImageLoaded(image) { } else { image.style.height = 'auto'; } - ScrollStore.emitPostScroll(); + + postListScrollChange(); } global.markdownImageLoaded = markdownImageLoaded; -- cgit v1.2.3-1-g7c22