ChronometerJS
A simple javascript library to create custom chronometers
Getting Started
To starts to use chronometerjs
in your application, you'll need to follow the steps below:
Installation
Install with npm:
npm install --save chronometerjs
Usage
Let's use the following index.html
in this example:
ChronometerJS Example Chronometer JS Start Chronometer
; const chronometer = schema: 0 20; const updateHTML = { documenttextContent = dataminutes; documenttextContent = dataseconds;}; chronometer; document;
Explanation
- Instantiate the class passing an object containing a property
schema
, that contains an array with the following structure:
seconds minutes hours
- The library uses the Observer Pattern, so we can create a function to receive the data every time that the chronometer changes, in this case, we use
updateHTML
function - Use the
subscribe()
method , that receives a function, to listen to the changes on the chronometer - To start the chronometer, we use the method
start()