ConnorAtherton / walkway

An easy way to animate SVG elements.
http://connoratherton.com/walkway
MIT License
4.37k stars 229 forks source link

Adding redraw logic on changing tab active state #29

Closed keeprock closed 8 years ago

keeprock commented 9 years ago

Added new boolean option «redrawOnFocus» and custom logic for processing tab focus change.

On «redrawOnFocus» true, every object will be redrawn from scratch every time user change active tab. Changing active window in OS will have no effect.

Callback function will not execute for obvious reasons. Such behavior can impact performance on a page and can lead to multiple complex callback functions calls.

We can set a parameter to check if animation was done at least once, but I will hold it for future pull requests.

If we leave «redrawOnCallback» undefined or set to false, everything will work as intended. Callback function will execute.

ConnorAtherton commented 8 years ago

@keeprock I've just merged a simpler change that will provide the behaviour you are looking for. With regards to your additions, I'm not sure why everything seems to have been changed -- formatting issues, mainly -- and I don't think the library should hardcode the redraw logic to any particular event. This works for tabs gaining focus again but won't work as-is if we want to bind that behaviour to a mouse event or a click event.

If you have some time, please look at the changes I added in #41 and let me know what you think.