-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(animation): Remove animation also from scene
Instead of only removing the animation from the "animation-manager", we now also remove it from the related scene with a new action "removeAnimationFromEverywhere". fix #85
- Loading branch information
1 parent
d26bd67
commit 5ce15ca
Showing
5 changed files
with
91 additions
and
62 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import * as constants from '../constants/index.js' | ||
import { getScenesWithAnimation } from '../selectors/index.js' | ||
import { removeAnimationFromScene } from './index.js' | ||
|
||
/* | ||
* Add a animation | ||
*/ | ||
export const addAnimation = animation => ({ | ||
animation, | ||
type: constants.ADD_ANIMATION | ||
}) | ||
|
||
/* | ||
* Update a animation | ||
*/ | ||
export const setAnimation = animation => ({ | ||
animation, | ||
type: constants.SET_ANIMATION | ||
}) | ||
|
||
/* | ||
* Start the playback of a animation | ||
*/ | ||
export const runAnimation = animationId => ({ | ||
animationId, | ||
type: constants.RUN_ANIMATION | ||
}) | ||
|
||
/* | ||
* Remove an animation from the animationManager | ||
*/ | ||
export const removeAnimation = animationId => ({ | ||
animationId, | ||
type: constants.REMOVE_ANIMATION | ||
}) | ||
|
||
/* | ||
* Remove the animation from everywhere | ||
*/ | ||
export const removeAnimationFromEverywhere = animationId => { | ||
return (dispatch, getState) => { | ||
|
||
const scenes = getScenesWithAnimation(getState(), { animationId }) | ||
|
||
// Remove animation from all scenes | ||
scenes.map(scene => { | ||
dispatch(removeAnimationFromScene(scene.id, animationId)) | ||
}) | ||
|
||
dispatch(removeAnimation(animationId)) | ||
} | ||
} | ||
|
||
|
||
/* | ||
* Add a keyframe to an animation | ||
*/ | ||
export const addKeyframe = (animationId, keyframeStep, keyframeProperty, keyframeValue) => ({ | ||
animationId, | ||
keyframeStep, | ||
keyframeProperty, | ||
keyframeValue, | ||
type: constants.ADD_KEYFRAME | ||
}) | ||
|
||
/* | ||
* Add keyframes to an animation | ||
*/ | ||
export const addKeyframes = (animationId, keyframeStep, keyframeProperties) => { | ||
return (dispatch, getState) => { | ||
Object.entries(keyframeProperties).map(keyframeProperty => { | ||
const [property, value] = keyframeProperty | ||
|
||
dispatch(addKeyframe(animationId, keyframeStep, property, value)) | ||
}) | ||
|
||
} | ||
} |
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
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
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
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