Comments (3)
At the moment it allows:
- Total number, using uppercase: {S} will print "63" seconds.
- Rest, using lowercase: {s} will print "3" seconds, this allows to represent the value with multiple units (63 seconds -> 1 minute and 3 seconds.
- Units without leading zeros, using a single letter: {s} will print "3" seconds.
- Units with leading zeros, using double letters: {ss} will print "03" seconds.
It is difficult to add more formatting options while keeping it simple. It could create conflicts since a format option would force leading zeros and another one would truncate. I recommend you to do it in two steps inside on_tick()
: first of all get the data and then process it the way you like:
on_tick(): function() {
var mins = timer1.lap('{mm}');
var secs = timer1.lap('{ss}');
var ms = timer1.lap('{ll}').substring(0,1);
document.querySelector('#timer').innerHTML = mins + ":" + secs + "." + ms;
}
Does this help you?
from tock.js.
Your solution works perfectly fine, Aitor!
Thank you for verbose feedback as well.
from tock.js.
As an addendum.
It seems timer1.lap('{ll}')[0];
or timer1.lap('{ll}').charAt(0);
are faster* than substring(0,1);
from tock.js.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tock.js.