Joystick UI component and controls for mobile browsers. Demo available:
import { createJoystick } from "joystick-ui";
import "joystick-ui/dist/main.css";
const { joystick, joystickControl } = createJoystick();
Prop | Type | Description |
---|---|---|
joystickClass |
string | Customize joystick styles. Default min-width: 180px and width: 20vw . |
thumbClass |
string | Customize moving thumb styles. Default width: 36px and height: 36px . |
enableTransition |
boolean | TODO. Transition is enabled by default. |
const animate = () => {
console.log(joystickControl.direction.normalize());
requestAnimationFrame(animate);
};
animate();
joystick
is a DOM element which can be rendered by any library or framework.
document.body.append(joystick);
return <div ref={(element) => element.append(joystick)} />;
return joystick;