Skip to content

Commit

Permalink
lint, renamed internal mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
reececomo committed Apr 26, 2024
1 parent 6c290f4 commit f6d3f0a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ npm install pixijs-actions
yarn add pixijs-actions
```

2. Import `pixijs-actions` somewhere in your application. The global mixins and their types are automatically registered when you import the library.
2. Import `pixijs-actions` somewhere in your application. The DisplayObject mixin and its types are automatically registered when you import the library.

3. Register the global ticker with your PixiJS app (or other render loop):

Expand Down
6 changes: 5 additions & 1 deletion src/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ export abstract class _ extends Action {
* @param categoryMask (Optional) Bitmask to filter which categories of actions to update.
* @param onErrorHandler (Optional) Handler errors from each action's tick.
*/
public static tick(deltaTimeMs: number, categoryMask: number | undefined = undefined, onErrorHandler?: (error: any) => void): void {
public static tick(
deltaTimeMs: number,
categoryMask: number | undefined = undefined,
onErrorHandler?: (error: any) => void
): void {
ActionTicker.tickAll(deltaTimeMs, categoryMask, onErrorHandler);
}

Expand Down
6 changes: 3 additions & 3 deletions src/mixin.ts → src/DisplayObject.mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { ActionTicker } from "./lib/ActionTicker";
import { getSpeed } from "./lib/utils/displayobject";

//
// ----- Global Mixin: -----
// ----- DisplayObject Mixin: -----
//

/**
* Register the global mixins for PIXI.DisplayObject.
* Register the mixins for PIXI.DisplayObject.
*
* @param displayObject A reference to `PIXI.DisplayObject`.
*/
export function registerGlobalMixin(displayObject: any): void {
export function registerDisplayObjectMixin(displayObject: any): void {
const prototype = displayObject.prototype;

// - Properties:
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/Action.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Container, Sprite } from 'pixi.js';
import { Action, TimingMode } from '../index';
// import { registerDisplayObjectMixin } from '../DisplayObject.mixin';

function simulateTime(seconds: number, steps: number = 100): void {
const tickMs = seconds / steps * 1_000;
Expand All @@ -10,8 +11,8 @@ function simulateTime(seconds: number, steps: number = 100): void {
}
}

/** Load the global mixin first. */
// beforeAll(() => registerGlobalMixin(DisplayObject));
/** Load the DisplayObject mixin first. */
// beforeAll(() => registerDisplayObjectMixin(DisplayObject));

describe('DefaultTimingMode static properties', () => {
it('should reflect the DefaultTimingModeEaseInOut on the root Action type', () => {
Expand Down
5 changes: 2 additions & 3 deletions src/actions/speed/SpeedToAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class SpeedToAction extends Action {
return new DelayAction(this.scaledDuration);
}

protected onSetupTicker(target: TargetNode, ticker: IActionTicker): any {
protected onSetupTicker(target: TargetNode): any {
return {
startSpeed: target.speed,
};
Expand All @@ -24,8 +24,7 @@ export class SpeedToAction extends Action {
target: TargetNode,
t: number,
dt: number,
ticker: IActionTicker,
deltaTime: number,
ticker: IActionTicker
): void {
target.speed = ticker.data.startSpeed + (this._speed - ticker.data.startSpeed) * t;
}
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import * as PIXI from 'pixi.js';

import { _ as Action } from "./Action";
import { TimingMode, TimingModeFn } from "./TimingMode";
import { registerGlobalMixin } from './mixin';
import { registerDisplayObjectMixin } from './DisplayObject.mixin';

//
// ----- [Side-effect] Initialize global mixin for DisplayObject: -----
// ----- [Side-effect] Initialize DisplayObject mixin: -----
//

registerGlobalMixin(PIXI.DisplayObject);
registerDisplayObjectMixin(PIXI.DisplayObject);

//
// ----- PixiJS Actions library: -----
//

export {
Action,
registerGlobalMixin,
registerDisplayObjectMixin,
TimingMode,
TimingModeFn,
};

//
// ----- Types and documentation for the global mixin: -----
// ----- Types and documentation for the DisplayObject mixin: -----
//

declare module 'pixi.js' {
Expand Down
2 changes: 2 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as PIXI from 'pixi.js';

declare global {

/** Time measured in seconds. */
Expand Down

0 comments on commit f6d3f0a

Please sign in to comment.