Last active
March 21, 2018 00:27
-
-
Save magicspon/350a454853635f73d781e2a59380b884 to your computer and use it in GitHub Desktop.
animation/transition end event prop
This file contains 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
export default (type = 'transition') => { | |
let types = | |
type === 'transition' | |
? { | |
OTransition: 'oTransitionEnd', | |
WebkitTransition: 'webkitTransitionEnd', | |
MozTransition: 'transitionend', | |
transition: 'transitionend' | |
} | |
: { | |
OAnimation: 'oAnimationEnd', | |
WebkitAnimation: 'webkitAnimationEnd', | |
MozAnimation: 'animationend', | |
animation: 'animationend' | |
} | |
const elem = document.createElement('div') | |
return Object.keys(types).reduce(function(prev, trans) { | |
return undefined !== elem.style[trans] ? types[trans] : prev | |
}, '') | |
} |
This file contains 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
import animationEnd from '@/utils/animationEnd' | |
describe('example', () => { | |
it('should return animationend when passed the string animation', () => { | |
const value = animationEnd('animation') | |
expect(value).toBe('animationend') | |
}) | |
it('should return transitionend when passed the string transition', () => { | |
const value = animationEnd('transition') | |
expect(value).toBe('transitionend') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment