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

Validate frameIndex in Animation #184

Closed
BenjaminDRichards opened this issue Feb 18, 2015 · 2 comments
Closed

Validate frameIndex in Animation #184

BenjaminDRichards opened this issue Feb 18, 2015 · 2 comments
Assignees
Labels
Milestone

Comments

@BenjaminDRichards
Copy link
Contributor

I've run into some odd issues with animations - they'll occasionally and unpredictably report an error, claiming that an invalid cell index was passed.

Long story short, it seems that sometimes, when creating animations during callbacks, they might occasionally have a negative frameIndex, and this causes a frame's worth of bork.

@BenjaminDRichards
Copy link
Contributor Author

The math in update() would sometimes return a negative frame index early in the object's life cycle.

I've changed mentions of _frameIndex (the internal value) to frameIndex (the setter, which performs validation). This appears to fix the issue.

BenjaminDRichards added a commit that referenced this issue Feb 19, 2015
Re issue #184

The last fix was not so good. It fixed problems with `onLoop` and `onComplete`, but it did it by avoiding `onLoop` and `onComplete` entirely.

The new fix employs mathematically rigorous methods to ensure that the `_frameIndex` property is within bounds before any external code is called. This should ensure that everything is fully functional at last.

Also rebuilt some docs.
@BenjaminDRichards
Copy link
Contributor Author

The last fix was not so good. It fixed problems with onLoop and onComplete, but it did it by avoiding onLoop and onComplete entirely.

The new fix employs mathematically rigorous methods to ensure that the _frameIndex property is within bounds before any external code is called. This should ensure that everything is fully functional at last.

BenjaminDRichards added a commit that referenced this issue Feb 19, 2015
Still re issue #184

In the race circumstance that the animation initialised on a negative frame count equal to the positive length, the code would set `frameCount=length`. This is an out-by-one error.

The erroneous code which set negative frame indices to nominally in-range positive indices read:

    this.length + this._frameIndex % this.length

The fix was to re-remainder the results:

    ( this.length + this._frameIndex % this.length ) % this.length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant