layout | title |
---|---|
default |
$state |
Every component has its own $state
instance that may be used for getting and setting state.
The component's $state instance may be accessed by dependency-injecting it into any event function:
FamousFramework.scene('example', {
events: {
'#foo': {
'click': function($state) {
// Get or set state
}
}
}
});
Aliases: .getState(key)
Parameters:
key {String|Array}
state name or path array (in the case of nested state)
Returns:
(Value) state value
Example:
$state.get('height');
Returns:
(Object) component's internal state object
Example:
$state.getStateObject();
Returns:
(Array) array with then last state set and the value
Example:
$state.getLatestStateChange();
Set component's state.
Aliases: .setState()
Parameters:
key {String|Array}
- state name of path (in the case of nested state)value {Any}
- value to set state tooptions {Object}
- transitions object
Returns:
(StateManager) component's instance of $state
Example:
$state.set('height', 200, { duration: 1000, curve: 'easeInOut' });
Set component's state after a set.
Aliases: .thenSetState()
Parameters:
key {String|Array}
- state name of path (in the case of nested state)value {Any}
- value to set state tooptions {Object}
- transitions object
Returns:
(StateManager) component's instance of $state
Example:
$state
.set('height', 200, { duration: 1000, curve: 'easeInOut' })
.thenSet('width', 200, { duration: 1000, curve: 'easeIn' });