Skip to content

Commit

Permalink
fix typescript issues
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberDex committed Mar 18, 2024
1 parent a3c9717 commit 2bef03b
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions src/ScrollBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ export class ScrollBox extends Container
eventMode: EventMode;
}[] = [];
protected visibleItems: Container[] = [];
protected pressedChild: Container;
protected pressedChild: Container | null = null;
protected ticker = Ticker.shared;
protected options: ScrollBoxOptions;
protected stopRenderHiddenItemsTimeout!: NodeJS.Timeout;
protected stopRenderHiddenItemsTimeout: NodeJS.Timeout | undefined;
protected onMouseScrollBinding = this.onMouseScroll.bind(this);
protected dragStarTouchPoint: Point;

Expand Down Expand Up @@ -123,15 +123,17 @@ export class ScrollBox extends Container
type: options.type,
elementsMargin: options.elementsMargin,
padding: options.padding,
vertPadding: options.vertPadding,
horPadding: options.horPadding,
topPadding: options.topPadding,
bottomPadding: options.bottomPadding,
leftPadding: options.leftPadding,
rightPadding: options.rightPadding,
paddingVert: options.paddingVert,
paddingHor: options.paddingHor,
paddingTop: options.paddingTop,
paddingBottom: options.paddingBottom,
paddingLeft: options.paddingLeft,
paddingRight: options.paddingRight,
});

this.addItems(options.items);
if (options.items) {

Check warning on line 134 in src/ScrollBox.ts

View workflow job for this annotation

GitHub Actions / build

Opening curly brace appears on the same line as controlling statement

Check warning on line 134 in src/ScrollBox.ts

View workflow job for this annotation

GitHub Actions / build

Opening curly brace appears on the same line as controlling statement
this.addItems(options.items);
}

if (this.hasBounds)
{
Expand Down Expand Up @@ -232,8 +234,8 @@ export class ScrollBox extends Container
const posY = item.y + list.y;

if (
posY + item.height + this.list.bottomPadding >= 0
&& posY - this.list.topPadding <= this.options.height
posY + item.height + this.list.paddingBottom >= 0
&& posY - this.list.paddingTop <= this.options.height
)
{
isVisible = true;
Expand Down Expand Up @@ -399,12 +401,12 @@ export class ScrollBox extends Container

protected get listHeight(): number
{
return this.list.height + this.list.topPadding + this.list.bottomPadding;
return this.list.height + this.list.paddingTop + this.list.paddingBottom;
}

protected get listWidth(): number
{
return this.list.width + this.list.leftPadding + this.list.rightPadding;
return this.list.width + this.list.paddingLeft + this.list.paddingRight;
}

/** Controls item positions and visibility. */
Expand Down Expand Up @@ -439,7 +441,7 @@ export class ScrollBox extends Container
0,
this.__width,
this.__height,
this.options.radius | 0,
this.options.radius ?? 0,
);
this.borderMask.eventMode = 'none';

Expand All @@ -457,7 +459,7 @@ export class ScrollBox extends Container
0,
this.__width,
this.__height,
this.options.radius | 0,
this.options.radius ?? 0,
);

if (this.options.type === 'horizontal')
Expand All @@ -478,14 +480,14 @@ export class ScrollBox extends Container
const maxWidth
= this.borderMask.width
- this.list.width
- this.list.leftPadding
- this.list.rightPadding;
- this.list.paddingLeft
- this.list.paddingRight;

const maxHeight
= this.borderMask.height
- this.list.height
- this.list.topPadding
- this.list.bottomPadding;
- this.list.paddingTop
- this.list.paddingBottom;

if (this.options.type === 'vertical')
{
Expand Down Expand Up @@ -525,13 +527,13 @@ export class ScrollBox extends Container
}
else if (
targetPos < 0
&& targetPos + this.listWidth + this.list.rightPadding
&& targetPos + this.listWidth + this.list.paddingRight
< this.__width
)
{
this._trackpad.xAxis.value = this.__width - this.listWidth;
}
else if (targetPos > this.list.leftPadding)
else if (targetPos > this.list.paddingLeft)
{
this._trackpad.xAxis.value = 0;
}
Expand All @@ -550,13 +552,13 @@ export class ScrollBox extends Container
}
else if (
targetPos < 0
&& targetPos + this.listHeight + this.list.bottomPadding
&& targetPos + this.listHeight + this.list.paddingBottom
< this.__height
)
{
this._trackpad.yAxis.value = this.__height - this.listHeight;
}
else if (targetPos > this.list.topPadding)
else if (targetPos > this.list.paddingTop)
{
this._trackpad.yAxis.value = 0;
}
Expand Down Expand Up @@ -596,7 +598,7 @@ export class ScrollBox extends Container
protected renderAllItems()
{
clearTimeout(this.stopRenderHiddenItemsTimeout);
this.stopRenderHiddenItemsTimeout = null;
this.stopRenderHiddenItemsTimeout = undefined;

if (this.options.disableDynamicRendering)
{
Expand All @@ -619,7 +621,7 @@ export class ScrollBox extends Container
if (this.stopRenderHiddenItemsTimeout)
{
clearTimeout(this.stopRenderHiddenItemsTimeout);
this.stopRenderHiddenItemsTimeout = null;
this.stopRenderHiddenItemsTimeout = undefined;
}

this.stopRenderHiddenItemsTimeout = setTimeout(() => this.updateVisibleItems(), 2000);
Expand Down Expand Up @@ -661,15 +663,15 @@ export class ScrollBox extends Container
? this.__width
- target.x
- target.width
- this.list.rightPadding
- this.list.paddingRight
: 0;

this._trackpad.yAxis.value
= !this.options.type || this.options.type === 'vertical'
? this.__height
- target.y
- target.height
- this.list.bottomPadding
- this.list.paddingBottom
: 0;

this.stopRenderHiddenItems();
Expand Down Expand Up @@ -733,8 +735,8 @@ export class ScrollBox extends Container
if (item.eventMode !== 'auto')
{
utils.isMobile.any
? item.emit('pointerupoutside', null)
: item.emit('mouseupoutside', null);
? item.emit('pointerupoutside', null as any)
: item.emit('mouseupoutside', null as any);

this.interactiveStorage.push({
item,
Expand Down

0 comments on commit 2bef03b

Please sign in to comment.