Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding "when to stop" functionality. #6

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

Conversation

alihalabyah
Copy link

No description provided.

@@ -165,6 +176,8 @@ var flipCounter = function(d, options){
_digitCheck(x, y);
// Do first animation
if (counter.auto === true) nextCount = setTimeout(_doCount, counter.pace);
// Stop counter
if (counter.value === counter.stop) _clearNext();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=== forces you to have an exact value to stop the counter.
I suggest if (counter.value >= counter.stop) _clearNext(); to stop the counter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point

@vivianreact
Copy link

`function _doCount(first) {
var first_run = typeof first === "undefined" ? false : first;

x = counter.value.toFixed(counter.decimals);

if (!first_run) counter.value += counter.inc;
y = counter.value.toFixed(counter.decimals);

if (y >= counter.stopValue) 
{
	y = counter.stopValue;
	_digitCheck(x, y);
	this.stop();
	counter.auto = false;
	_clearNext();
}
else
{
	_digitCheck(x, y);
}

// Do first animation
if (counter.auto === true) nextCount = setTimeout(_doCount, counter.pace);

}`

Should add y = counter.stopValue to ensure the stop value is what you want instead of bigger or smaller value

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

Successfully merging this pull request may close these issues.

3 participants