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

Tweening functions are returning NaN #52

Closed
charliematters opened this issue Nov 3, 2015 · 1 comment
Closed

Tweening functions are returning NaN #52

charliematters opened this issue Nov 3, 2015 · 1 comment

Comments

@charliematters
Copy link

I'm having some issues with cancelling a running transition with {duration:0, stackBehavior: DESTRUCTIVE}.

After chasing it down, the problem is demonstrated by the following code:

var easeInOutQuad= function(t, b, _c, d) {
    var c = _c - b;
    if ((t /= d / 2) < 1) {
        return c / 2 * t * t + b;
    } else {
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    }
}

easeInOutQuad(0,1,1,0) // Produces NaN

isNaN(t/d) == isNaN(0/0) == true

This has a number of knock-on problems which I now have to add guards for.

Is it worth adding divide-by-zero protection to the functions?

@chenglou
Copy link
Owner

Eeeeh, you're right. Sorry for the trouble.

I don't think the tween-functions library should have its functions changed. A duration of 0 is ambiguous for a simple easing function.

I've pushed a change in this lib instead, where a duration of 0 will jump you to the end, as expected.

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

No branches or pull requests

2 participants