-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
40 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 |
---|---|---|
|
@@ -61,4 +61,4 @@ | |
:fullscreen? false | ||
:header? true} | ||
:timeline {:time 0 | ||
:paused? true}}) | ||
:paused? false}}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
(ns renderer.timeline.views | ||
(:require | ||
["@xzdarcy/react-timeline-editor" :refer [Timeline]] | ||
[clojure.string :as str] | ||
[re-frame.core :as rf] | ||
[reagent.core :as r] | ||
[renderer.components :as comp])) | ||
|
||
(defn time-rendered | ||
[time] | ||
(let [float (-> time (rem 1) (* 100) str js/parseInt str (.padStart 2 "0") (str/replace "0." "")) | ||
min (-> time (/ 60) str js/parseInt str (.padStart 2 "0")) | ||
sec (-> time (rem 60) str js/parseInt str (.padStart 2 "0"))] | ||
(str min ":" sec ":" float))) | ||
|
||
(defn root | ||
[] | ||
(let [data @(rf/subscribe [:timeline/rows]) | ||
effects @(rf/subscribe [:timeline/effects]) | ||
time @(rf/subscribe [:timeline/time]) | ||
paused? @(rf/subscribe [:timeline/paused?])] | ||
time @(rf/subscribe [:timeline/time-formatted]) | ||
paused? @(rf/subscribe [:timeline/paused?]) | ||
engine (atom nil)] | ||
[:div | ||
[:div.toolbar.level-1 | ||
(if paused? | ||
[comp/icon-button "play" {:on-click #(rf/dispatch [:timeline/pause])}] | ||
[comp/icon-button "pause" {:on-click #(rf/dispatch [:timeline/play])}]) | ||
[:span.p-2 [time-rendered time]]] | ||
[comp/icon-button "play" {:on-click #(.play @engine)}] | ||
[comp/icon-button "pause" {:on-click #(.pause @engine)}]) | ||
[:span.p-2 time]] | ||
[:> Timeline {:editor-data data | ||
:effects effects | ||
:onCursorDrag #(rf/dispatch [:timeline/set-time %1]) | ||
:onCursorDragStart #(rf/dispatch [:timeline/pause]) | ||
:ref (fn [this] | ||
(when this | ||
(reset! engine this) | ||
(doseq | ||
[[e f] | ||
[["play" #(rf/dispatch [:timeline/play])] ;; Prevent navigation | ||
["paused" #(rf/dispatch [:timeline/pause])] | ||
["afterSetTime" #(rf/dispatch-sync [:timeline/set-time (.-time %)])] | ||
["setTimeByTick" #(rf/dispatch-sync [:timeline/set-time (.-time %)])]]] | ||
(.on (.-listener this) e f)))) | ||
;; :onCursorDrag #(rf/dispatch [:timeline/set-time %]) | ||
;; :onCursorDragStart #(rf/dispatch [:timeline/pause]) | ||
:onClickAction #(rf/dispatch [:element/select (keyword (.. %2 -action -id))])}]])) |