Skip to content

Commit 89e9b9d

Browse files
authored
Hot-fix: Make ScrollBox Type Defaults to 'vertical' (#218)
* Hot-fix: Make ScrollBox Type Defaults to 'vertical' * Fix list type and button event type * More type fixes
1 parent c9ee211 commit 89e9b9d

7 files changed

+14
-14
lines changed

src/ScrollBox.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,9 @@ export class ScrollBox extends Container
940940

941941
protected get isVertical(): boolean
942942
{
943-
return this.options.type === 'vertical';
943+
const type = this.options.type ?? 'vertical';
944+
945+
return type === 'vertical';
944946
}
945947

946948
protected get isHorizontal(): boolean
@@ -950,8 +952,6 @@ export class ScrollBox extends Container
950952

951953
protected get isBidirectional(): boolean
952954
{
953-
const type = this.options.type ?? 'bidirectional';
954-
955-
return type === 'bidirectional';
955+
return this.options.type === 'bidirectional';
956956
}
957957
}

src/stories/list/ListSprite.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { preload } from '../utils/loader';
1111
import { action } from '@storybook/addon-actions';
1212

1313
const args = {
14-
type: LIST_TYPE.reverse(),
14+
type: LIST_TYPE,
1515
fontColor: '#000000',
1616
elementsMargin: 29,
1717
itemsAmount: 12,

src/stories/scrollBox/ScrollBoxDynamicDimensions.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const args = {
1212
fontColor: '#000000',
1313
backgroundColor: '#F5E3A9',
1414
itemsAmount: 100,
15-
type: [...LIST_TYPE],
15+
type: [null, ...LIST_TYPE],
1616
};
1717

1818
export const UseDynamicDimensions: StoryFn<typeof args & { type: ListType }> = (

src/stories/scrollBox/ScrollBoxGraphics.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const args = {
2323
disableEasing: false,
2424
globalScroll: true,
2525
shiftScroll: false,
26-
type: LIST_TYPE.reverse(),
26+
type: [null, ...LIST_TYPE],
2727
innerListWidth: 1000,
2828
onPress: action('Button pressed'),
2929
};

src/stories/scrollBox/ScrollBoxProximity.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const args = {
2020
elementsWidth: 300,
2121
elementsHeight: 80,
2222
itemsAmount: 100,
23-
type: [...LIST_TYPE],
23+
type: [null, ...LIST_TYPE],
2424
fadeSpeed: 0.5,
2525
};
2626

src/stories/switcher/Switcher.stories.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PixiStory, StoryFn } from '@pixi/storybook-renderer';
22
import { Switcher } from '../../Switcher';
33
import { centerElement } from '../../utils/helpers/resize';
4-
import { BUTTON_EVENTS } from '../../utils/HelpTypes';
4+
import { BUTTON_EVENTS, ButtonEvent } from '../../utils/HelpTypes';
55
import { argTypes, getDefaultArgs } from '../utils/argTypes';
66
import { preload } from '../utils/loader';
77
import { action } from '@storybook/addon-actions';
@@ -15,9 +15,9 @@ const args = {
1515

1616
export const Sprites: StoryFn<
1717
typeof args & {
18-
triggerEvent1: string;
19-
triggerEvent2: string;
20-
triggerEvent3: string;
18+
triggerEvent1: ButtonEvent;
19+
triggerEvent2: ButtonEvent;
20+
triggerEvent3: ButtonEvent;
2121
}
2222
> = ({ action, triggerEvent1, triggerEvent2, triggerEvent3 }, context) =>
2323
new PixiStory<typeof args>({

src/utils/HelpTypes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface DragObject extends Container
1010
dragGlobalStart: Point;
1111
}
1212

13-
export const BUTTON_EVENTS = ['onPress', 'onDown', 'onUp', 'onHover', 'onOut', 'onUpOut'];
13+
export const BUTTON_EVENTS = ['onPress', 'onDown', 'onUp', 'onHover', 'onOut', 'onUpOut'] as const;
1414

1515
export type ButtonEvent = (typeof BUTTON_EVENTS)[number];
1616

@@ -25,5 +25,5 @@ export type Padding =
2525
bottom?: number;
2626
};
2727

28-
export const LIST_TYPE = ['vertical', 'horizontal', 'bidirectional'];
28+
export const LIST_TYPE = ['vertical', 'horizontal', 'bidirectional'] as const;
2929

0 commit comments

Comments
 (0)