| | import { Container, Sprite, Graphics } from "pixi.js"; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | export function set_cursor( |
| | child: Container | Sprite | Graphics, |
| | cursor: "unset" | "none" |
| | ): void { |
| | if (child instanceof Container) { |
| | child.cursor = cursor; |
| | } else if ("cursor" in child) { |
| | (child as any).cursor = cursor; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | export function recurse_set_cursor( |
| | children: (Container | Sprite | Graphics)[], |
| | cursor: "unset" | "none" |
| | ): void { |
| | for (const child of children) { |
| | set_cursor(child, cursor); |
| | if (child instanceof Container && child.children.length > 0) { |
| | recurse_set_cursor( |
| | child.children as (Container | Sprite | Graphics)[], |
| | cursor |
| | ); |
| | } |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | export function safe_remove_child( |
| | child: Container | Sprite | Graphics | null |
| | ): void { |
| | if (child && child.parent) { |
| | child.parent.removeChild(child); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | export function safe_destroy<T extends { destroy: (options?: any) => void }>( |
| | obj: T | null |
| | ): null { |
| | if (obj) { |
| | safe_remove_child(obj as any); |
| | obj.destroy({ children: true }); |
| | } |
| | return null; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | export function clear_timeout(timeout: number | null): null { |
| | if (timeout !== null) { |
| | window.clearTimeout(timeout); |
| | } |
| | return null; |
| | } |
| |
|