soulwire/sketch.js

Regulate Large Delta Times Caused by Blur/Focus Events

Closed this issue · 3 comments

When autopause is enabled and blur/focus events are starting and stopping the animation., the delta time (ctx.dt) can get incredibly large. It is of course obvious why this is happening, since tons of time is still passing, even while the animation isn't running. I am not sure of the best way to handle this.

I suppose you could store the current time when the blur occurs, and then get the current time when the focus occurs, and remove that amount from the delta calculation once things start up again. Any other ideas?

On a similar note, maybe you could just add blur/focus into the overridable instance methods, and we can handle regulating delta and other blur/focus issues manually, if that is out of the scope of sketch.js

Thanks for all this great feedback Jack, much appreciated :)

This should be fixed in the v1.1 branch and there are unit tests in there for ensuring this. Check out the branch and have a poke around if you want, I'll be merging it into master once I've re-implemented retina support.

Excellent! Looks like you have considered most of my concerns for the next version ;) I am happy to help.

I will take a look at v1.1 in the next few days.

Should be fixed in master now, which is at v1.1