mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 05:46:25 +08:00
Only call updateScrubberValues onupdate when necessary
When the page is scrolled, goToIndex is called, or the page is loaded, various listeners result in the scrubber being updated with a new position and values. However, if goToNumber is called, the scrubber will not be updated. Accordingly, we add logic to the scrubber's onupdate to update itself, but only when needed, as indicated by this This saves us a LOT of unnecessary calls, and makes scrubber movement smoother.
This commit is contained in:
parent
db71f8bf68
commit
dc8b203037
@ -353,6 +353,8 @@ export default class PostStream extends Component {
|
||||
|
||||
return Promise.all([$container.promise(), this.stream.loadPromise]).then(() => {
|
||||
this.updateScrubber();
|
||||
this.stream.forceUpdateScrubber = true;
|
||||
|
||||
const index = $item.data('index');
|
||||
m.redraw.sync();
|
||||
|
||||
|
@ -90,7 +90,10 @@ export default class PostStreamScrubber extends Component {
|
||||
}
|
||||
|
||||
onupdate() {
|
||||
this.stream.loadPromise.then(() => this.updateScrubberValues({ animate: true, forceHeightChange: true }));
|
||||
if (this.stream.forceUpdateScrubber) {
|
||||
this.stream.forceUpdateScrubber = false;
|
||||
this.stream.loadPromise.then(() => this.updateScrubberValues({ animate: true, forceHeightChange: true }));
|
||||
}
|
||||
}
|
||||
|
||||
oncreate(vnode) {
|
||||
|
@ -37,6 +37,18 @@ class PostStreamState {
|
||||
*/
|
||||
this.description = '';
|
||||
|
||||
/**
|
||||
* When the page is scrolled, goToIndex is called, or the page is loaded,
|
||||
* various listeners result in the scrubber being updated with a new
|
||||
* position and values. However, if goToNumber is called, the scrubber
|
||||
* will not be updated. Accordingly, we add logic to the scrubber's
|
||||
* onupdate to update itself, but only when needed, as indicated by this
|
||||
* property.
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.forceUpdateScrubber = false;
|
||||
|
||||
this.show(includedPosts);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user