0.2.0 • Published 4 years ago

number-shuffler v0.2.0

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

Number Shuffler

This module shuffle NUMBER.

demo

Installation

npm

$ npm install number-shuffler

cdn

<script src="https://unpkg.com/number-shuffler@0.1.0/dist/number-shuffler.js"></script>

Usage

import

import this module. (if install via npm only)

import * as NumberShuffler from "number-shuffler";

initialize

pass element that display number in init method argument.

let ns = NumberShuffler.init(TargetElement);

set option

Set the options if necessary.

ns.setOption({
    interval: 50,
    digit: 6,
});
optiontypedescriptiondefault
formatbooleanflag for format a number.true
intervalnumberinterval to switch numbers.(msec)30
digitnumberthe number of digits3

start / stop

// start shuffling a number.
ns.start()

// stop shuffling a number.
ns.stop()

Example

HTML

<div id="numBox">000,000</div>
<button type="button" id="startBtn">start</button>
<button type="button" id="stopBtn">stop</button>

Javascript

import * as NumberShuffler from "number-shuffler";

document.addEventListener("DOMContentLoaded", function() {
  let numBoxElm = document.getElementById('numBox');
  let ns = NumberShuffler.init(numBoxElm);

  ns.setOption({
    interval: 50,
    digit: 6,
  });

  document.getElementById('startBtn').addEventListener('click', function(){
    ns.start();
  });
  document.getElementById('stopBtn').addEventListener('click', function(){
    ns.stop();
  });
});
0.2.0

4 years ago

0.1.0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago