Skip to content

Commit

Permalink
Wire up the maxFrameIndex to the simulation-controls.
Browse files Browse the repository at this point in the history
It doesn't actually limit anything because the selector caches the value too intensely. Part of #10.
  • Loading branch information
jkomoros committed Nov 21, 2021
1 parent 7c67e4a commit e8248d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/simulation-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
selectRunIndex,
selectSimulationIndex,
selectSimulationsMap,
selectCurrentSimulationMaxRunIndex
selectCurrentSimulationMaxRunIndex,
selectCurrentSimulationRunMaxFrameIndex
} from "../selectors.js";

import {
Expand All @@ -27,6 +28,7 @@ class SimulationControls extends connect(store)(LitElement) {
_simulationsMap: { type:Object },
_simulationIndex: { type:Number },
_simulationMaxRunIndex: { type:Number },
_maxFrameIndex: { type: Number },
_frameIndex: { type: Number },
_runIndex: {type: Number},
};
Expand Down Expand Up @@ -62,7 +64,7 @@ class SimulationControls extends connect(store)(LitElement) {
</div>
<div>
<label for='frameIndex'>Frame</label>
<input id='frameIndex' .value=${this._frameIndex} type='number' min='0' @change=${this._handleFrameIndexChanged}>
<input id='frameIndex' .value=${this._frameIndex} type='number' min='0' max=${this._maxFrameIndex} @change=${this._handleFrameIndexChanged}>
</div>
</div>
`;
Expand All @@ -73,6 +75,7 @@ class SimulationControls extends connect(store)(LitElement) {
this._simulationsMap = selectSimulationsMap(state);
this._simulationIndex = selectSimulationIndex(state);
this._simulationMaxRunIndex = selectCurrentSimulationMaxRunIndex(state);
this._maxFrameIndex = selectCurrentSimulationRunMaxFrameIndex(state);
this._frameIndex = selectFrameIndex(state);
this._runIndex = selectRunIndex(state);
}
Expand Down
5 changes: 5 additions & 0 deletions src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ const selectCurrentSimulationRun = createSelector(
}
);

export const selectCurrentSimulationRunMaxFrameIndex = createSelector(
selectCurrentSimulationRun,
(run) => run ? run.maxFrameIndex : Number.MAX_SAFE_INTEGER
);

export const selectCurrentFrame = createSelector(
selectCurrentSimulationRun,
selectFrameIndex,
Expand Down

0 comments on commit e8248d1

Please sign in to comment.