Skip to content

Commit

Permalink
fix(animation): Don't reset the scene when animation is done
Browse files Browse the repository at this point in the history
When a scene has multiple animations, the first animation that is done should not restart the whole
scene. We added a quick fix for this, but in the future we have to make ssure that an animation has
it's own progress.

fix #112
  • Loading branch information
TimPietrusky committed Oct 10, 2019
1 parent 2eb6b95 commit 4866618
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
28 changes: 28 additions & 0 deletions src/components/timeline/sketch_timeline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"timeline": {
"scenes": [{
"sceneId": "1acee3e0-e02c-11e9-aa5a-053c07f0fa34",
"timelineSceneId": "2d3f80f0-eb23-11e9-a506-1d4f9a09fff9",
"adapt": true,
"type": "static",
"added": 1570687192703,
"started": 1570688810596,
"priority": 0,
"animations": [{
"animationId": "asd-asdf-asdf-asdf-asdf-asdf",
"type": "repeat",
"started": 1570688810596
}]
}, {
"sceneId": "6878c220-e02f-11e9-b1ac-b1b9c8742475",
"timelineSceneId": "ec3e6ef0-eb26-11e9-af75-e516d6b192d7",
"adapt": true,
"type": "static",
"added": 1570688801631,
"started": 1570688806691,
"priority": 0
}],
"playing": false,
"progress": 0
}
}
13 changes: 9 additions & 4 deletions src/components/timeline/timeline-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,15 @@ class TimelineAnimation extends LitElement {
}

ended() {
// Animation is done
this.dispatchEvent(new CustomEvent('animation-ended', {
detail: {}
}))
// This is a quick fix to restart the animation when it's done
this.started = new Date().getTime()

// The real fix would be to still let the scene know that the animation ended
// but only restart the animation and not the whole scene
// // Animation is done
// this.dispatchEvent(new CustomEvent('animation-ended', {
// detail: {}
// }))
}

shouldUpdate(changedProperties) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/timeline/timeline-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class TimelineScene extends connect(store)(LitElement) {
}

animationEnded(e) {
// @TODO: Do not reset the scene if one of it's animations is done
// every anmation has to have it's own progress and type
if (this.timelineScene.type === SCENE_TYPE_STATIC) {
const scene = {
sceneId: this.timelineScene.sceneId,
Expand Down

0 comments on commit 4866618

Please sign in to comment.