Skip to content

Instantly share code, notes, and snippets.

@elliottkember
Last active March 14, 2019 14:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliottkember/d714f2bfc8fde24c5406 to your computer and use it in GitHub Desktop.
Save elliottkember/d714f2bfc8fde24c5406 to your computer and use it in GitHub Desktop.
Framer.js per-transition animationOptions!
myLayer.states.stateAnimationOptions =
'a-b':
time: 0.1
'b-c':
time: 0.8
'c-d':
time: 0.5
myLayer.states.add
a: opacity: 1
b: opacity: 0
c: opacity: 0.5
myLayer.states.on Events.StateWillSwitch, (oldState, newState) ->
key = "#{oldState}-#{newState}"
if newAnimationOptions = myLayer.states.stateAnimationOptions?[key]
myLayer.states.animationOptions = _.merge myLayer.states.animationOptions, newAnimationOptions

Here's a concept of how we could manage state transitions in Framer. Currently, you can set a animationOptions property on a layer's state manager. Using the Events.StateWillSwitch notification, we should be able to change these attributes before a state change takes place, and by concatenating the state names we can create unique state-to-state transition options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment