Skip to content

Commit

Permalink
Fix transitions taking at least 1 second
Browse files Browse the repository at this point in the history
  • Loading branch information
fedegratti committed Nov 24, 2022
1 parent 9faaeb9 commit 7b70127
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v7.0.0
v7.0.1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ohzi-core",
"version": "7.0.0",
"version": "7.0.1",
"description": "OHZI Core Library",
"source": "src/index.js",
"module": "build/index.module.js",
Expand Down
22 changes: 19 additions & 3 deletions src/view_components/transition/ActionSequencerBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class ActionSequencerBuilder
const tracks = animation_data.animation_tracks;
const triggers = animation_data.triggers;

const initial_tracks = this.state_to_tracks(this.initial_state_data);
const initial_tracks = this.state_to_tracks(this.initial_state_data, this.get_longest_time(animation_data.animation_tracks));

for (let i = 0; i < initial_tracks.length; i++)
{
Expand Down Expand Up @@ -52,7 +52,7 @@ export default class ActionSequencerBuilder
return sequencer;
}

state_to_tracks(state)
state_to_tracks(state, longest_time)
{
const tracks = [];

Expand All @@ -63,7 +63,7 @@ export default class ActionSequencerBuilder
tracks.push({
attribute_name: keys[i],
from_time: 0,
to_time: 1,
to_time: longest_time < 1 ? longest_time : 1,
to_value: state[keys[i]],
initial: true,
easing_function: 'ease_in_out_cubic'
Expand Down Expand Up @@ -103,4 +103,20 @@ export default class ActionSequencerBuilder

return sequencer;
}

get_longest_time(tracks)
{
let longest_time = -1;

for (let i = 0; i < tracks.length; i++)
{
const track = tracks[i];

const track_time = track.to_time;

longest_time = track_time > longest_time ? track_time : longest_time;
}

return longest_time;
}
}

0 comments on commit 7b70127

Please sign in to comment.