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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ipad-dual-joystick

v0.1.6

Published

A React package that implements a dual joystick for ipads.

Downloads

35

Readme

ipad-dual-joystick

Description

ipad-dual-joystick is a sleek, mobile-optimized React component that brings dual on-screen joysticks and optional buttons (A and B) to your web games and interactive apps.
Designed for iPhones, iPads, and modern Android devices, it gives you the precision and responsiveness of a game controller, directly in the browser.

Perfect for games, simulations, and interactive experiences that require fluid, touch-friendly controls.

Benefits

  • Responsive Design: Works flawlessly on different screen sizes, orientations, and aspect ratios.
  • Optional controls: Only show joysticks or buttons if the corresponding callbacks are provided.
  • Customizable: Easily tweak colors, sizes, positions, and offsets through SCSS variables.
  • Lightweight & Dependency-Free: No frameworks, no bloated libraries, just clean React code.
  • Multiplatform: Optimized for iOS and Android touch devices.
  • Intuitive & Smooth: Pointer events, dead-zone handling, and dynamic joystick scaling ensure precise input.
  • Future-Proof: Ready for games and apps that require rapid prototyping or full-scale production.

Installation

Install via npm:

npm install ipad-dual-joystick

Usage

import React from "react";
// Import Javascript Module
import { MobileJoystickControls } from "ipad-dual-joystick";
// Import SCSS/CSS styling
import "ipad-dual-joystick/dist/styles.scss";

const MyGame: React.FC = () => {
    const handleLeftMove = (dx: number, dy: number) => {
        console.log("Left joystick:", dx, dy);
    };

    const handleRightMove = (dx: number, dy: number) => {
        console.log("Right joystick:", dx, dy);
    };

    const handleUp = (active: boolean) => console.log("Up:", active);
    const handleDown = (active: boolean) => console.log("Down:", active);
    const handleA = (active: boolean) => console.log("A:", active);
    const handleB = (active: boolean) => console.log("B:", active);

    return (
        <MobileJoystickControls
            onLeftJoystickMove={handleLeftMove}   // optional
            onRightJoystickMove={handleRightMove} // optional
            onUp={handleUp}                       // optional
            onDown={handleDown}                   // optional
            onButtonA={handleA}                   // optional
            onButtonB={handleB}                   // optional
            autoFade={true}                       // optional
        />
    );
};

Styling

You can fully customize the appearance of joysticks and buttons using SCSS:

$joystick-bg: rgba(50, 50, 50, 0.5);
$joystick-handle-bg: #ff0000;
$joystick-handle-active-bg: #00ff00;
$button-bg: #333333;
$button-active-bg: #ff8800;

@import "ipad-dual-joystick/dist/MobileJoystickControls.scss";

Variables you can customize:

  • $joystick-bg
  • $joystick-handle-bg
  • $joystick-handle-active-bg
  • $button-bg
  • $button-active-bg
  • $button-color
  • $button-active-color
  • $joystick-size
  • $joystick-handle-size
  • $button-size
  • $button-gap
  • $joystick-offset-vertical
  • $joystick-offset-horizontal
  • $button-offset-vertical

Features

  • Dual joysticks with smooth analog input
  • Optional action buttons (A and B)
  • Dead-zone and scaling for precise control
  • Responsive layout for portrait and landscape modes
  • Fully customizable via SCSS or CSS

Props

Optional callbacks: if you don’t provide a callback, the corresponding joystick or button will not render.

| Prop | Type | Optional | Description | |-----------------------| ---------------------------------- |----------|--------------------------------------------| | onLeftJoystickMove | (dx: number, dy: number) => void | Yes | Callback for left joystick movement | | onRightJoystickMove | (dx: number, dy: number) => void | Yes | Callback for right joystick movement | | onUp | (active: boolean) => void | Yes | Callback for "Up" button press/release | | onDown | (active: boolean) => void | Yes | Callback for "Down" button press/release | | onButtonA | (active: boolean) => void | Yes | Callback for "A" button press/release | | onButtonB | (active: boolean) => void | Yes | Callback for "B" button press/release | | autoFade | boolean | Yes | If True fade after 5 seconds of inactivity |

License

MIT