scroller: add guards

old-stable24
Varun Patil 2022-10-16 11:46:26 -07:00
parent 7de0ae7c9d
commit adafc999c9
1 changed files with 8 additions and 0 deletions

View File

@ -93,9 +93,14 @@ export default class ScrollerManager extends Mixins(GlobalMixin) {
/** Recycler scroll event, must be called by timeline */
public recyclerScrolled(event?: any) {
// Ignore if not initialized
if (!this.ticks.length) return;
// Move hover cursor to px position
this.cursorY = utils.roundHalf(event ? event.target.scrollTop * this.height / this.recyclerHeight : 0);
this.moveHoverCursor(this.cursorY);
// Show the scroller for some time
if (this.scrollingRecyclerTimer) window.clearTimeout(this.scrollingRecyclerTimer);
this.scrollingRecycler = true;
this.scrollingRecyclerTimer = window.setTimeout(() => {
@ -124,6 +129,9 @@ export default class ScrollerManager extends Mixins(GlobalMixin) {
/** Re-create tick data */
private reflowNow() {
// Ignore if not initialized
if (!this.recycler?.$refs.wrapper) return;
// Refresh height of recycler
this.recyclerHeight = this.recycler.$refs.wrapper.clientHeight;