From c38e8023d00299551757260d633863e0e7e1f5e7 Mon Sep 17 00:00:00 2001 From: Baz Utsahajit Date: Sun, 10 Mar 2024 21:41:02 +0000 Subject: [PATCH] Chore: ScrollBox Tweaks --- src/ScrollBox.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/ScrollBox.ts b/src/ScrollBox.ts index fd9d5b59..43d5f70d 100644 --- a/src/ScrollBox.ts +++ b/src/ScrollBox.ts @@ -68,6 +68,7 @@ export class ScrollBox extends Container protected stopRenderHiddenItemsTimeout!: NodeJS.Timeout; protected onMouseScrollBinding = this.onMouseScroll.bind(this); protected dragStarTouchPoint: Point; + protected isOver = false; /** * @param options @@ -349,6 +350,16 @@ export class ScrollBox extends Container this.stopRenderHiddenItems(); }); + this.on('pointerover', () => + { + this.isOver = true; + }); + + this.on('pointerout', () => + { + this.isOver = false; + }); + this.on('globalpointermove', (e: FederatedPointerEvent) => { if (!this.isDragging) return; @@ -510,17 +521,12 @@ export class ScrollBox extends Container protected onMouseScroll(event: WheelEvent): void { + if (!this.isOver) return; this.renderAllItems(); - if ( - this.options.type === 'horizontal' - && (typeof event.deltaX !== 'undefined' - || typeof event.deltaY !== 'undefined') - ) + if (this.options.type === 'horizontal' && typeof event.deltaX !== 'undefined') { - const targetPos = event.deltaY - ? this.list.x - event.deltaY - : this.list.x - event.deltaX; + const targetPos = this.list.x - event.deltaX; if (this.listWidth < this.__width) {