Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bbazukun123 committed Jan 31, 2025
1 parent 92d4993 commit e9aff0e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 29 deletions.
8 changes: 5 additions & 3 deletions src/Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export class Input extends Container
this._add(this.lastInputData);
}

if (this.input) {
if (this.input)
{
this.input.value = '';
}
}
Expand Down Expand Up @@ -720,10 +721,11 @@ export class Input extends Container
this.inputMask.position.set(this.paddingLeft, this.paddingTop);
}

protected onPaste(e: any) {
protected onPaste(e: any)
{
e.preventDefault();

const text = (e.clipboardData || (window as any).clipboardData).getData("text");
const text = (e.clipboardData || (window as any).clipboardData).getData('text');

if (!text) return;

Expand Down
3 changes: 2 additions & 1 deletion src/List.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Container, ContainerChild } from 'pixi.js';

export type ListType = 'horizontal' | 'vertical';
export type ListType = 'horizontal' | 'vertical' | 'bidirectional';

export type ListOptions<C extends ContainerChild = ContainerChild> = {
elementsMargin?: number;
Expand Down Expand Up @@ -306,6 +306,7 @@ export class List<C extends ContainerChild = ContainerChild> extends Container<C
x += elementsMargin + child.width;
break;

case 'bidirectional':
default: // bidirectional
child.x = x;
child.y = y;
Expand Down
13 changes: 5 additions & 8 deletions src/ScrollBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export type ScrollBoxOptions = {
dragTrashHold?: number;
globalScroll?: boolean;
shiftScroll?: boolean;
bidirectionalScroll?: boolean;
proximityRange?: number;
proximityDebounce?: number;
disableProximityCheck?: boolean;
Expand Down Expand Up @@ -100,19 +99,19 @@ export class ScrollBox extends Container

protected get isVertical(): boolean
{
const type = this.options.type ?? 'vertical';

return type === 'vertical';
return this.options.type === 'vertical';
}

protected get isHorizontal(): boolean
{
return !this.isVertical;
return this.options.type === 'horizontal';
}

protected get isBidirectional(): boolean
{
return !!this.options.bidirectionalScroll;
const type = this.options.type ?? 'bidirectional';

return type === 'bidirectional';
}

/**
Expand All @@ -130,8 +129,6 @@ export class ScrollBox extends Container
* @param {boolean} [options.globalScroll=true] - if true, the ScrollBox will scroll even if the mouse is not over it.
* @param {boolean} [options.shiftScroll=false] - if true, the ScrollBox will only scroll horizontally if the shift key
* is pressed, and the type is set to 'horizontal'.
* @param {boolean} [options.bidirectionalScroll=false] - if true, the ScrollBox will scroll both vertically and
* horizontally, accommodating overflows in both directions.
*/
constructor(options?: ScrollBoxOptions)
{
Expand Down
4 changes: 2 additions & 2 deletions src/stories/list/ListGraphics.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { argTypes, getDefaultArgs } from '../utils/argTypes';
import { action } from '@storybook/addon-actions';

const args = {
type: [null, 'horizontal', 'vertical'],
type: [null, 'horizontal', 'vertical', 'bidirectional'],
fontColor: '#000000',
bgColor: '#f5e3a9',
width: 271,
Expand All @@ -24,7 +24,7 @@ const args = {
onPress: action('Button pressed'),
};

export const UseGraphics: StoryFn<typeof args & { type: 'horizontal' | 'vertical' }> = (
export const UseGraphics: StoryFn<typeof args & { type: 'horizontal' | 'vertical' | 'bidirectional' }> = (
{
type,
fontColor,
Expand Down
4 changes: 2 additions & 2 deletions src/stories/list/ListSprite.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { preload } from '../utils/loader';
import { action } from '@storybook/addon-actions';

const args = {
type: [null, 'horizontal', 'vertical'],
type: [null, 'horizontal', 'vertical', 'bidirectional'],
fontColor: '#000000',
elementsMargin: 29,
itemsAmount: 10,
onPress: action('Button pressed'),
};

export const UseSprite: StoryFn<typeof args & { type: 'horizontal' | 'vertical' }> = (
export const UseSprite: StoryFn<typeof args & { type: 'horizontal' | 'vertical' | 'bidirectional' }> = (
{ fontColor, elementsMargin, itemsAmount, onPress, type },
context,
) =>
Expand Down
9 changes: 3 additions & 6 deletions src/stories/scrollBox/ScrollBoxGraphics.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ const args = {
elementsPadding: 10,
elementsWidth: 300,
elementsHeight: 80,
itemsAmount: 100,
itemsAmount: 1,
disableEasing: false,
globalScroll: true,
shiftScroll: false,
type: [undefined, 'vertical', 'horizontal'],
bidirectionalScroll: false,
type: [undefined, 'vertical', 'horizontal', 'bidirectional'],
onPress: action('Button pressed'),
};

export const UseGraphics: StoryFn<typeof args & { type: 'vertical' | 'horizontal' | undefined }> = (
export const UseGraphics: StoryFn<typeof args & { type: 'vertical' | 'horizontal' | 'bidirectional' | undefined }> = (
{
fontColor,
elementsMargin,
Expand All @@ -43,7 +42,6 @@ export const UseGraphics: StoryFn<typeof args & { type: 'vertical' | 'horizontal
onPress,
globalScroll,
shiftScroll,
bidirectionalScroll,
},
context,
) =>
Expand Down Expand Up @@ -92,7 +90,6 @@ export const UseGraphics: StoryFn<typeof args & { type: 'vertical' | 'horizontal
type,
globalScroll,
shiftScroll,
bidirectionalScroll,
});

scrollBox.addItems(items);
Expand Down
4 changes: 2 additions & 2 deletions src/stories/scrollBox/ScrollBoxProximity.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ const args = {
elementsWidth: 300,
elementsHeight: 80,
itemsAmount: 100,
type: [undefined, 'vertical', 'horizontal'],
type: [undefined, 'vertical', 'horizontal', 'bidirectional'],
fadeSpeed: 0.5,
};

const items: FancyButton[] = [];
const inRangeCache: boolean[] = [];

export const ProximityEvent: StoryFn<
typeof args & { type: 'vertical' | 'horizontal' | undefined }
typeof args & { type: 'vertical' | 'horizontal' | 'bidirectional' | undefined }
> = (
{
width,
Expand Down
7 changes: 2 additions & 5 deletions src/stories/scrollBox/ScrollBoxSprite.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ const args = {
elementsMargin: 6,
itemsAmount: 100,
disableEasing: false,
type: [undefined, 'vertical', 'horizontal'],
bidirectionalScroll: false,
type: [undefined, 'vertical', 'horizontal', 'bidirectional'],
onPress: action('Button pressed'),
globalScroll: true,
shiftScroll: false,
};

export const UseSprite: StoryFn<typeof args & { type: 'vertical' | 'horizontal' | undefined }> = (
export const UseSprite: StoryFn<typeof args & { type: 'vertical' | 'horizontal' | 'bidirectional' | undefined }> = (
{
fontColor,
elementsMargin,
Expand All @@ -30,7 +29,6 @@ export const UseSprite: StoryFn<typeof args & { type: 'vertical' | 'horizontal'
onPress,
globalScroll,
shiftScroll,
bidirectionalScroll,
},
context,
) =>
Expand Down Expand Up @@ -74,7 +72,6 @@ export const UseSprite: StoryFn<typeof args & { type: 'vertical' | 'horizontal'
type,
globalScroll,
shiftScroll,
bidirectionalScroll,
});

scrollBox.addItems(items);
Expand Down

0 comments on commit e9aff0e

Please sign in to comment.