From 7bd715d6e2e54df11a1c33125338c677d6d51ffe Mon Sep 17 00:00:00 2001 From: Kia Date: Tue, 12 Mar 2019 17:49:41 -0400 Subject: [PATCH] closes #34 --- src/app/components/App.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/components/App.jsx b/src/app/components/App.jsx index c27c18a..cb973d6 100644 --- a/src/app/components/App.jsx +++ b/src/app/components/App.jsx @@ -174,15 +174,23 @@ class App extends Component { // time travel bar change handleBarChange(e) { - const { data } = this.state; + const { data, isPlayingIndex } = this.state; const { id, action, state } = data[e.target.value]; - + // forward or past + const currentIsPlayingIndex = e.target.value; + const forward = currentIsPlayingIndex > isPlayingIndex; this.setState({ id, action, state, - isPlayingIndex: parseInt(e.target.value), + isPlayingIndex: parseInt(currentIsPlayingIndex), }); + // Displays to screen + if (forward) { + this.toTheFuture(); + } else { + this.toThePast(); + } } // function to travel to the FUTURE