Skip to content

Commit

Permalink
Chore: ScrollBox Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bbazukun123 committed Mar 10, 2024
1 parent 90c3dbc commit c38e802
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/ScrollBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit c38e802

Please sign in to comment.