Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

roll-a-die

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roll-a-die

Simple 3D dice roll using CSS3 animation.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
45
increased by21.62%
Maintainers
1
Weekly downloads
 
Created
Source

Roll A Die

npm package

Simple 3D dice roll animator by CSS3 Animation.

Demo

Vanilla JS

Copy dist/roll-a-die.js into your library folder Load it into your HTML script

<script type="text/javascript" src="path/to/roll-a-die.js"></script>

You can use the UNPKG link https://unpkg.com/roll-a-die@1.3.0/dist/roll-a-die.js. Remember to update the package number to the most recent.

Call the method with its options.

rollADie({ element, numberOfDice: 2, callback});

With npm (and CommonJS builder)

Install with npm.

npm install --save roll-a-die

Install with yarn.

yarn add roll-a-die

import the library

ES5

const rollADie = require('roll-a-die');

ES6

import rollADie from 'roll-a-die';

Call the method

rollADie({ element, numberOfDice: 2, callback });
rollADie({ element, numberOfDice: 2, callback, soundVolume: 1 });
rollADie({ element, numberOfDice: 2, callback, delay: 1000 });
rollADie({ element, numberOfDice: 2, callback, values: [3, 4] });

Parameter Definitions

  • element: The element to render die animation on. Type: HTMLElement
  • numberOfDice: The number of dice to use.` Type: number
  • callback: Called when animation is finished. Returns an array of the values from throw. Type: Function
  • soundVolume: Set volume of audio between 0 and 1. (Optional) Defaults to 1. Type: number
  • delay: Time in milliseconds to delay before removing animations (Optional). Type: number
  • values: Values to show on die face. When provided, it overrides library genrated values. (Optional). Type: Array of numbers

Thanks

License

MIT License

Keywords

FAQs

Package last updated on 21 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc