-
-
Save tanepiper/2627022 to your computer and use it in GitHub Desktop.
CSS animation with callback style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cssTo = (elem, prop, time, easing, callback)-> | |
| time = "#{time / 1000}s" | |
| transitions = [] | |
| for key, value of prop | |
| transitions.push "#{key} #{time} #{easing}" | |
| transition = transitions.join ', ' | |
| listener = (e)-> | |
| elem.removeEventListener 'webkitTransitionEnd', listener | |
| elem.style['-webkit-transition'] = '' | |
| callback?() | |
| elem.addEventListener 'webkitTransitionEnd', listener | |
| elem.style['-webkit-transition'] = transition | |
| for key, value of prop | |
| elem.style[key] = value |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage