Skip to content
This repository was archived by the owner on Apr 2, 2019. It is now read-only.

Added odometer-digit-added event #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added odometer-digit-added event #53

wants to merge 1 commit into from

Conversation

julen
Copy link

@julen julen commented Mar 31, 2014

I needed a way to set the odometer's width in order to smoothly animate it when the number of digits increased/decreased, so I ended up adding an odometer-digit-added event which is triggered every time a digit is inserted to the DOM.

You can check the JSFiddle I created in order to showcase the end result (I included the compiled JS result code in the commit only to be able to use it from the JSFiddle as an external resource).

There might probably be a better way to handle this, but I don't know the source code well enough to determine that.

This is useful for animating the width of the odometer in case the number
of digits increases or decreases.
@adamschwartz
Copy link
Contributor

Looks great! Only tweak I'd suggest is listening to the transitionEnd event (where available) over using the setInterval to detect the end of the digit addition.

@julen
Copy link
Author

julen commented Mar 31, 2014

Hmm just checked but the effect is not the same if I listen to transitionend — basically I get the same results by listening to odometerdone: first it cycles through numbers, and once the animation is over, the width expands.

In my example the width slowly expands while the new digit is rotating.

@adamschwartz
Copy link
Contributor

I'm not sure I understand why the setInterval is needed at all then. Check out my altered jsFiddle.

@julen
Copy link
Author

julen commented Apr 1, 2014

You're right, I kept it from the initial implementation I had (without this new event) so not sure why I included it in the JSFiddle in the first place. In any case the event is needed unless the library sets the width after each digit is inserted.

@julen
Copy link
Author

julen commented Oct 22, 2014

Any chance to have this merged? Ideally I'd like to use the CommonJS module from npm instead of a custom build with this enhancement.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants