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

Fix bug causing AnimatedValue to freeze after same value is entered #155

Closed

Conversation

kotaweav
Copy link
Contributor

There appears to be a bug in Dashing.AnimatedValue which causes the
AnimatedValue to freeze if the new value is equal to the current. The
source of the bug seems to be due to the comparison in num == to
being between a float and a string. By default, CoffeeScript compiles
== to Javascript's ===. Instead, if we use backticks, we can use a
"raw Javascript" command which allows us to call ==.

There appears to be a bug in `Dashing.AnimatedValue` which causes the
AnimatedValue to freeze if the new value is equal to the current. The
source of the bug seems to be due to the comparison in `num == to`
being between a float and a string. By default, CoffeeScript compiles
`==` to Javascript's `===`. Instead, if we use backticks, we can use a
"raw Javascript" command which allows us to call `==`.
Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

LGTM, just one question to @femtogram.

@@ -96,7 +96,7 @@ Dashing.AnimatedValue =
else
timer = "interval_#{k}"
num = if (!isNaN(@[k]) && @[k]?) then @[k] else 0
unless @[timer] || num == to
unless @[timer] || `num == to`
Copy link
Member

Choose a reason for hiding this comment

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

@femtogram what about moving the parseFloat to before this line? Otherwise, I think we should leave a comment here so that other developers don't accidentally remove the backticks, and to help if moving away from coffeescript later and having to rewrite this code (see #72). WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh gee, completely missed this. Yes, I think moving the parseFloat was probably the better solution, but I see you've added the change with the note! With a rewrite the note might be helpful to prevent the same bug moving forward.

kinow added a commit that referenced this pull request Jun 3, 2020
@kinow kinow closed this in 49f0ba7 Jun 3, 2020
@kinow
Copy link
Member

kinow commented Jun 3, 2020

Added a NOTE to the code, and also the changelog entry. Will be included in the next release. Thanks @femtogram !

@kinow kinow self-assigned this Jun 3, 2020
@kinow kinow added this to the 1.3.0 milestone Jun 3, 2020
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.

2 participants