gzap
GSAP wrapper that doesn't mutate the source object/DOM node. Animates on shadow DOM with support for computed styles. Made with intent to use with React, but supports other usecases as well.
npm install gzap
Example
; { superprops thisstate = circleCSS: background: '#BADA55' width: 100 height: 100 borderRadius: '50%' } { gzap } { return <div className="circle" ref= this_ref = c style=thisstatecircleCSS></div> ; }
; { superprops thisstate = circleCSS: background: '#BADA55' width: 100 height: 100 borderRadius: '50%' } { let tl = gzap tl tl tl } { return <div className="circle" ref= this_ref = c style=thisstatecircleCSS></div> ; }
API
gzap.to(target, duration, vars)
Implements TweenMax.to with the following modifications to vars:
onUpdate: (apply, styles) => {}
onComplete: (apply, styles) => {}
apply(object) A function that safely assigns the animated styles to object. Uses Object.assign({}, sourceObject, styles)
styles An object containing all the animated styles. All properties has been converted to Style Object Properties
gzap.from(target, duration, vars)
Implements TweenMax.from with the following modifications to vars:
onUpdate: (apply, styles) => {}
onComplete: (apply, styles) => {}
apply(object) A function that safely assigns the animated styles to object. Uses Object.assign({}, sourceObject, styles)
styles An object containing all the animated styles. All properties has been converted to Style Object Properties
gzap.fromTo(target, duration, fromVars, toVars)
Implements TweenMax.fromTo with the following modifications to fromVars and toVars:
onUpdate: (apply, styles) => {}
onComplete: (apply, styles) => {}
apply(object) A function that safely assigns the animated styles to object. Uses Object.assign({}, sourceObject, styles)
styles An object containing all the animated styles. All properties has been converted to Style Object Properties
let timeline = gzap.tl(vars)
Implements TimelineMax with the following modifications:
timeline // Uses gzap.totimeline // Uses gzap.fromtimeline // Uses gzap.fromTo
Since GZAP is a wrapper, all other GSAP functionality should be available