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

joystickjs

v1.0.3

Published

A simple and customisable virtual joystick

Downloads

15

Readme

joystickJS

A simple and customisable virtual joystic

npm

Menu

Install

Download the joystickJS.js file from here and include the file in your code.

<script src="path/to/joystickJS.min.js"></script>

// OR

npm i joystickjs

// OR

<script src="https://rawgit.com/alexoakland/joystickJS/master/dist/joystickJS.min.js"></script>

Package manager installations coming soon.


Usage

Create a new Joystick and store it in a variable. Currently options are required which are given to the joystick in the form of a json object described below.

let joystick = new Joystick( {
        element: document.getElementById("joystick"),
        frontColor: "red",
        backColor: "blue",
        size: 200,
        position: {
            y: 200, x: 200
        },
        mode: "normal", //Can be xAxis, yAxis or stickToEdge
        returnToCenter: true,
    });

Options

element: The element in HTML you want to encapsulate the joystick.

   element: document.getElementById("joystick"),

frontColor: The color of the front part of the joystick. Can be any HTML accepted color.

   frontColor: "red",

backColor: The color of the front part of the joystick. Can be any HTML accepted color.

   backColor: "blue",

size: The diamater of the circle.

   size: 200,

position: Given in the form of an x and y position, which translates into pixels on the screen.

   position: {
            y: 200, x: 200
        },

mode: Defines the mode of the joystick

   mode: "normal", //Normal use
   //or
   mode: "xAxis", //Locks to x axis (left to right).
   //or
   mode: "yAxis", //Locks to y axis (up to down).
   //or
   mode: "stickToEdge", //Forces the joystick to stick to the edge.

returnToCenter: If true the joystick will return to the center after it's moved. Doesn't work if stickToEdge is set to true.

   returnToCenter: true,

Events

To recieve data from the joystick, called the moved function, which accepts a callback, and in that callback include a parameter. The parameter will contain the data from the joystick under event.details as a json object.

joystick.moved(function(event){
       console.log(event.details);
    });

The data received includes:

  • position: A json object containing the x and y position of the joystick based on the entire screen.
  • distance: The distance from the center of the joystick.
  • angle: The angle of movement.
  • coordinates: A json object containing the x and y position of the joystick based on the joystick.

Issues and Feature requests

If you come across any issues or have suggestions for a feature, feel free to mention them.


Contributing

Before contributing please take a look at the Code of Conduct