mdgriffith / elm-style-animation

The style animation library for Elm!
http://package.elm-lang.org/packages/mdgriffith/elm-style-animation/latest
BSD 3-Clause "New" or "Revised" License
440 stars 40 forks source link

Infinite Loop #34

Closed rupertlssmith closed 7 years ago

rupertlssmith commented 7 years ago

Version 3.5.2

I created an animation with this easing:

controlBarHideEasing = Animation.easing { duration = 1.2e-1 * second , ease = Ease.inBack }

The animation is to change from "left = -6 px" to "left = 24 px". The animation completes succesfully, but Animation events continue to Tick in an infinite loop after this.

Interestingly, if I make the animation smaller, say from -6 to -8, it completes ok.

I tried varying the duration, but no joy.

I replaced the easing function with: Ease.inOut Ease.inBack Ease.outQuad, which gives me more or less the same effect and it does not infinite loop.

I suspect there is some kind of rounding error in the code relating to the Ease.inBack function, it appears to never manage to reach 24px, but gets stuck at 23.999...?

To test this hypothesis, I also dumped out the model here it is:

controlBarStyle = Animation { steps = [Step], style = [Property "left" { position = 23.999999999999993, velocity = 0, target = 24, unit = "px", interpolation = Spring { stiffness = 170, damping = 26 }, interpolationOverride = Just (Easing { progress = 1, duration = 120, ease = , start = -6 }) }], timing = { current = 1486483235957, dt = 17 }, running = True, interruption = [] } }

mdgriffith commented 7 years ago

I just released version 3.5.3 which fixed a floating point rounding error. I'm 99.9% sure it addresses your issue, though let me know if it persists!

rupertlssmith commented 7 years ago

Or are you 99.999999999999993% sure? :-P Thanks for fixing.

mdgriffith commented 7 years ago

XD no problemo!