mirror of
https://github.com/flarum/framework.git
synced 2024-11-26 10:14:16 +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
8640ce83b5
commit
d57a9f100a
|
@ -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…
Reference in New Issue
Block a user