npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-joystick-component

v6.2.1

Published

A snazzy React joystick component

Downloads

15,789

Readme

React Joystick Component

Bundle Size

Click here to see examples

npm i react-joystick-component --save
yarn add react-joystick-component
import { Joystick } from 'react-joystick-component';
<Joystick size={100} sticky={true} baseColor="red" stickColor="blue" move={handleMove} stop={handleStop}></Joystick>

Component Props - as described by IJoystickProps - all are optional

| Prop | Type | Description | |---|---|---| | size | number | The size in px of the Joystick base | | stickSize | number | The size in px of the Joystick stick (if unspecified, joystick size is relative to the size value | | baseColor | string | The color of the Joystick base | | stickColor | string | The color of the Stick | | throttle | number | The throttling rate of the move callback | | sticky | Boolean | Should the joystick stay where it is when the interaction ends | | stickImage | string | The image to be shown for the joystick | | baseImage | string | The image to be shown for the pad | | followCursor | Boolean | Make the stick follow the cursor position | | move | Function | Callback fired on every mouse move, not throttled unless a throttling rate is provided as above | | stop | Function | Callback fired when the user releases the joystick | | start | Function | Callback fired when the user starts moving the Joystick | | disabled | Boolean | When true, block any usage of the Joystick. This will also apply the joystick-disabled and joystick-base-disabled classNames | | stickShape | JoystickShape | The shape of the joystick default = circle| | baseShape | JoystickShape | The shape of the joystick default = circle| | controlPlaneShape | JoystickShape | Override the default shape behaviour of the control plane - circle, square, axisX, axisY| | minDistance | number | Percentage 0-100 - the minimum distance to start receive IJoystickMove events| | pos | {x: number, y: number}| Override the joystick position (doesn't work if the user is interacting. You can use disabled to force this)|

import {JoystickShape} from "./shape.enum"; 
interface IJoystickProps {
    size?: number;
    stickSize?: number;
    baseColor?: string;
    stickColor?: string;
    disabled?: boolean;
    throttle?: number;
    sticky?: boolean;
    stickImage?: string;
    baseImage?: string;
    followCursor?: boolean;
    move?: (event: IJoystickUpdateEvent) => void;
    stop?: (event: IJoystickUpdateEvent) => void;
    start?: (event: IJoystickUpdateEvent) => void;
    baseShape?: JoystickShape;
    stickShape?: JoystickShape;
    controlPlaneShape?: JoystickShape;
    minDistance?: number;
    pos: {x: number, y: number}
}
type JoystickDirection = "FORWARD" | "RIGHT" | "LEFT" | "BACKWARD";

export interface IJoystickUpdateEvent {
    type: "move" | "stop" | "start";
    x: number | null;
    y: number | null;
    direction: JoystickDirection | null;
    distance: number; // Percentile 0-100% of joystick 
}