@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.
21 lines (19 loc) • 721 B
text/typescript
/**
* Sets the priority attribute on a menu element, determining its position in the menu.
* Lower priority elements appear on the left, higher priority on the right.
*/
export function setElementPriority(button: HTMLElement, priority: number) {
button.setAttribute("priority", String(priority));
}
/**
* Gets the priority attribute from a menu element.
* @returns The priority value, or undefined if not set or not a valid number.
*/
export function getElementPriority(button: HTMLElement): number | undefined {
const priority = button.getAttribute("priority");
if (priority) {
const val = Number.parseFloat(priority);
if (!Number.isNaN(val)) return val;
}
return undefined;
}