Skip to content

delay

The delay function provides a way to create a function that will run a callback after a specified number of milliseconds of ticker time.

It ensures that the delay is in sync with the ticker from the nearest context provider, making it ideal for animations or syncing with other actions based on a common ticker time.

This function must be called within a SolidJS tracking scope, such as a component or another function, that is a descendant of PixiApplicationProvider, PixiCanvas or TickerProvider

import { delay } from "pixi-solid/utils";
import { Text } from "pixi-solid";
const DelayedCallbackComponent = () => {
const handlePointerDown = () => {
console.log("Pointer down");
delay(1000, () => {
console.log("1 second has passed on the ticker");
});
};
return <Text text={"Click me"} onpointerdown={handlePointerDown} />;
};
  • When you need to delay execution in a way that is synchronized with the ticker.
  • For animations or other operations that depend on the ticker's timing.
  • To avoid using external time measurements like setTimeout in ticker-dependent contexts.