1
0
mirror of https://github.com/flarum/core.git synced 2025-10-24 13:16:08 +02:00

Optimize ScrollListener performance

Listen to "scroll" event and throttle callback executions instead
of actively polling for changes to the scroll position.

Fixes #1222.
This commit is contained in:
Franz Liedke
2019-09-05 02:17:09 +02:00
parent ed51f9ff0a
commit 0191babb05
3 changed files with 24 additions and 22 deletions

View File

@@ -2,7 +2,6 @@ import Component from '../../common/Component';
import ScrollListener from '../../common/utils/ScrollListener';
import PostLoading from './LoadingPost';
import anchorScroll from '../../common/utils/anchorScroll';
import mixin from '../../common/utils/mixin';
import evented from '../../common/utils/evented';
import ReplyPlaceholder from './ReplyPlaceholder';
import Button from '../../common/components/Button';
@@ -586,7 +585,7 @@ class PostStream extends Component {
*/
unpause() {
this.paused = false;
this.scrollListener.update(true);
this.scrollListener.update();
this.trigger('unpaused');
}
}

View File

@@ -2,7 +2,6 @@ import Component from '../../common/Component';
import icon from '../../common/helpers/icon';
import ScrollListener from '../../common/utils/ScrollListener';
import SubtreeRetainer from '../../common/utils/SubtreeRetainer';
import computed from '../../common/utils/computed';
import formatNumber from '../../common/utils/formatNumber';
/**
@@ -365,7 +364,7 @@ export default class PostStreamScrubber extends Component {
}
onresize() {
this.scrollListener.update(true);
this.scrollListener.update();
// Adjust the height of the scrollbar so that it fills the height of
// the sidebar and doesn't overlap the footer.