Giter Club home page Giter Club logo

odometer's Introduction

Odometer

Odometer is a Javascript and CSS library for smoothly transitioning numbers.

odometer's People

Contributors

abeisgoat avatar adamschwartz avatar akre54 avatar evanpurkhiser avatar johnrandom avatar kevva avatar korzha avatar marcneuwirth avatar zackbloom avatar zinkkrysty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

odometer's Issues

Least significant decimal dropped if it is a 0.

Is there any way to force the least significant decimal digit to remain visible if 0?

For instance

When I try a format: '(,ddd).dddd', on a number like 123456.1230

The number 123.456,123 is displayed. I would like to keep that 0 visible.

BTW, thanks for repairing the format issue.

Classnames not being removed when tab is hidden

Repro steps:

  1. Visit docs page (http://github.hubspot.com/odometer)
  2. Switch to a different browser tab of the same window
  3. Wait 10 seconds
  4. Switch back
  5. Observe:
    screen shot 2013-10-18 at 8 49 35 pm

I'm guessing when the browser tab is blurred the setInterval in the example is continuing to fire but the CSS transition events are not. Not sure what we can do exactly, but probably worth looking into.

Side note: if you open http://github.hubspot.com/odometer/docs/welcome/ in a background tab (an unfocused tab), no matter how long you wait, when you switch to it, the "ODOMETER" CSS animation starts when you focus the tab.

Trailing zeros after decimal point

We have a cenario where we'd like to always display 2 digits after decimal point, even if both of them are zero.

Currently, numbers like 420.00 are animated as 420 only, with the decimal point and trailing zeros removed.

Current format we're using is '(,ddd).dd'.

Are we doing something wrong, or is this a limitation of the library? In which case, will support be added for these type of scenarios?

Thanks in advance.

execute on scroll position

Trying to trigger the setTimeout(function) to a scroll position of 850 but need some help....

$(document).ready(function() {
    var below_850 = false;

    $(document).scroll(function() {
        var top = $(document).scrollTop();
        below_850 = (top > 850);
    });

    setTimeout(function(){
      $('.odometer').html('652348');
    }, 1000);
});

Decimals and combinations of zeroes seem to break comma formatting

When working with numbers over 1,000. I honestly can't spot a very discrete pattern. Example 3 shows that you can have three consecutive non-trailing zeroes and still break formatting.

Example 5 shows you can have three consecutive non-trailing zeroes and follow formatting.

If someone hasn't already run into this issue I'm going to try to patch it.

window.odometerOptions = {
    format: '(,ddd).dd'
};

When it doesn't work:

Example $50,520.00:
example 1

Example $9,400.00:
example 2

Example $50,001.00
example 3

When it works:

Example $9,400.01:
example 4

Example $50,000.01:
example 5

Thanks!

Checkerboard pattern shows at times

When the numbers fly by very fast, sometimes you see the browsers checkerboard pattern since it can't paint new regions fast enough.

Here's an example:

Format not working

At the bottom of the body (after I load odometer), I have this:

window.odometerOptions = {
    auto: true, // Don't automatically initialize everything with class 'odometer'
    selector: '.odometer', // Change the selector used to automatically find things to be animated
    format: 'd', // Change how digit groups are formatted, and how many digits are shown after the decimal point
    duration: 1000, // Change how long the javascript expects the CSS animation to take
    theme: 'default', // Specify the theme (if you have more than one theme css file on the page)
    animation: 'count' // Count is a simpler animation method which just increments the value,
    // use it when you're looking for something more subtle.
};

It all works except for the format. Why?

Also: The Docs page is unclear: 1) It doesn't say where to download the themes, 2) It doesn't say what the different animations are.

wrong odometer animation

ok, this is really only a small problem. I bumped up the animation time to 10 seconds on my system. And i noticed that the meter is not really animated as a real odometer. A real odometer advances the next digit only when the previous digit reaches 9. Your animation "fractionally" advances all digits continously from start number to destination number, all at the same time, which makes it a little bit weird to watch...

running multiple occasions (same theme)

I would like to run 4 occasions of .odometer on the same page - only with different results e.g.: 1223 | 100029 | 272728 | 8282

How would you write the init?

setTimeout(function(){
$('.odometer').html('1223');
}, 1000);

Decimal issues when incrementing number below 1

If you take a look at this site here after clicking on "Play", it takes you to a screen with a the odometer on the left side intialised to a number below 1.

When you choose a right answer for the question, the odometer points increase.

The problem is, when, say for example, the points increase from 0.25 to 0.55.

While the increment animation is taking triggers, the 0 the integer part vanishes and you see only a .26 while incrementing. I want the odometer to retain the 0 in the integer part of the decimal to be retained while the animation is taking place.

What is the solution to retain the zero while incrementing the decimals below 1? I tried the format option, but that didn't seem to work. Or did I do it wrong?

Noticeable flicker on Safari

Works great on Chrome but I noticed bad flicker of the whole page right when the digits stop spinning on both desktop and iOS Safari. Not sure I've explained this well enough, let me know if you need more information.

Off screen - reset options

I'm running an Odometer on a slider, which when off screen fails to update causing the Odometer to fail. It seems calling $('.odometer').html(5) only runs when the Odometer is on screen, any call when this is off screen causes it to fail.

Is there (or could there be) a way to reset the Odometer to 0, so it can be used again? Or .destroy()?

Add even triggers for animation done

This is a feature request, if it's already in I didn't find it on the docs.

It would be very helpful to have some event trigger when it's done cycling through numbers after you update it.

Thanks.

additional white digits in car like theme

First of all: great work !!
Only one remark: i would like a new theme exactly like the car theme, except that not only the last digit is white, but ALL digits after the "decimal" are white. All digits before "decimal" are black. The current car theme only renders the last digit white (always). Is this possible ?

Animated Issue

When I update new count and the odometer is sliding( that is concurrent). odometer has no slide effect at all.

Or, should I check the odometer has 'animating' class at before?

Apply willChange 1 second before animation and schedule removal

element.willChange support is picking up.

Be sure to read this article from DevOpera before implementing this!

It's now possible to hint to the browser that an animation will occur. It comes with a memory and time overhead and disable the normal optimization a browser will do, so implement it wisely. But it can speed up the animation start time and smoothness. Real tests needs to be conducted in order to see how much, but I'm hoping it's considerably.

left zeros

Is there a way to keep left zeros on the string in case of pre-defined number of digits?

Using (,ddd).dddd format only displays on animate

When I try a format: '(,ddd).dddd', when at rest the format shows:
123456.1234
While animating it shows correctly:
123.456,1234

A .dddd format trims the trailing 0s in the decimal places. Is that expected behaviour?
odometer-format-issue

Experiencing some lag when scrolling

Really cool plugin. However, i'm trigging the numbers animation on scroll and when it comes to the point, numbers do really slow down a bit the site scrolling and general performance.

I understand this type of effect cannot be achieved 100% via CSS4, but is anyone else experiencing this issue?

I've implemented odometer in a one-page site with some other plugins like wow.js, stellar.js etc...

Cannot center .odometer container element without using !important or padding

Please correct me if I'm mistaken, but to effectively center the .odometer container element you have to use !important to override a few CSS rules. The default styles within odometer-theme-default.css (lines 1-9) are

.odometer.odometer-auto-theme, .odometer.odometer-theme-default {
  display: -moz-inline-box;
  -moz-box-orient: vertical;
  display: block;
  vertical-align: middle;
  *vertical-align: auto;
  position: relative;
  position: relative;
}

to center the .odometer container the following overrides are necessary & are not applied without !important

.odometer {
    text-align: center !important;
    display: block !important;
    font-family: 'roboto' !important;
}

or

.odometer {
    padding: 60px 129px;
}

works without !important but is much more difficult to center considered in the context of media queries. Padding is how the GitHub Stars odometer is working on http://github.hubspot.com/odometer/.

The default theme also enforces Helvetica Neue as the font family & this too requires !important to override. Why not just use

.odometer.odometer-auto-theme, .odometer.odometer-theme-default {
    font-family: inherit;
}

?

The cascade of my stylesheets is in the correct order with my custom styles referenced below odometer-theme-default.css & therefore is not the cause of this issue.

innerText doesn't work with Firefox

The default value used for initialize the Odometer use the innerText property. (Odometer.init)
This property is not implemented in Firefox, to fix it i've changed the value to :

el.odometer = new Odometer {el, value: if el.textContent then el.textContent else el.innerText }

Floating Points/Decimals not working

I have a case where I was using this plugin to create an odometer for a value of 182.57. Rather than generating it as a floating point (or throwing an error) the plugin interpreted it as 18,257 (18k). The decimal point is ignored. I was able to generate this with any floating point value.

I assume that patching this would require some manipulation of the functionality that generates content for odometer-formatting-mark class.

No support for currancy symbols

I would like to be able to prepend a '$' at the beginning of the number to use the odometer for a currency display. Adding it to the format isnt working (it sticks the '$' into the number. Would it be possible to add this option?

Change innerText before animations end

If you change innerText before the last animation as ended, the animations will stop and you'll see a delayed value on odometer

$0.innerText = 300; setTimeout(function() { $0.innerText = 400 }, 100);

What odometer will display is 300, if you do $0.innerText = 500 it will show 400

Execute when in viewport

Hi - sorry if this is the wrong place, I've been trying to get it to load when in the viewport. I have a number of them but they all activate from the start. I'm new at JS but struggling.

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.