From 5489f68c0e75eab76fc16b6257605d5f75b87be4 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 25 Jun 2021 10:59:57 +0200 Subject: ready state / disabled editor and player --- pages/editor.tsx | 22 ++++++++++++++++------ styles/editor.css | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/pages/editor.tsx b/pages/editor.tsx index 0290fe1..40aeefc 100644 --- a/pages/editor.tsx +++ b/pages/editor.tsx @@ -71,7 +71,7 @@ interface project { timeline: boolean; video: { available: boolean; - fullyloaded: boolean; + playable: boolean; }; }; update: { @@ -102,7 +102,7 @@ var project = createState({ timeline: false, video: { available: false, - fullyloaded: false, + playable: false, }, }, update: { @@ -504,6 +504,8 @@ function TimelineEditor() { var mouseX = 0; + var ready = useHookstate(project).ready; + var timelineRef = useRef(null); var selectionAreaRef = useRef(null); useEffect(() => { @@ -653,7 +655,7 @@ function TimelineEditor() { }, []); return
@@ -810,6 +812,12 @@ function DefaultSettings() { var reader = new FileReader(); reader.addEventListener('load', ev => { player.loadVideo(ev.target.result as string); + project.ready.video.available.set(true); + + player.player.addEventListener( + 'canplaythrough', + () => project.ready.video.playable.set(true), + ); player.player.addEventListener('play', () => project.timeline.playing.set(true)); player.player.addEventListener('pause', () => project.timeline.playing.set(false)); @@ -949,6 +957,8 @@ export default function Index() { document.addEventListener('gesturechange', preventDefault); }, []); + var ready = useHookstate(project).ready; + return <>
@@ -963,12 +973,12 @@ export default function Index() {
-
+
-
+
{ player.next(); diff --git a/styles/editor.css b/styles/editor.css index 95cff49..9ae1baa 100644 --- a/styles/editor.css +++ b/styles/editor.css @@ -169,6 +169,7 @@ .tools .time .framerate, .tools .time .timecode { + user-select: none; transition-property: opacity, color; transition-duration: 150ms; } @@ -279,7 +280,13 @@ line-height: 0; } +.player.disabled .outer { + border-color: var(--c400) !important; +} + .appGrid .viewer .player .outer { + transition-property: border-color; + transition-duration: 150ms; border: 8px solid var(--piss); border-radius: 8px; } @@ -311,11 +318,26 @@ .appGrid .viewer .controls .MuiFab-root.playPause { background-color: var(--blue); } +.appGrid .viewer .controls.disabled .playPause, +.appGrid .viewer .controls .playPause.disabled { + color: var(--c700); + opacity: .6; + background-color: var(--c400); +} .appGrid .viewer .controls .MuiFab-root { color: var(--fg); } +.appGrid .viewer .controls.disabled .MuiFab-root { + color: var(--c700); + opacity: .6; + pointer-events: none; +} +.appGrid .viewer .controls .MuiFab-root { + transition-property: background-color, color, opacity; + transition-duration: 150ms; +} .appGrid .viewer .controls .MuiFab-root:not(.playPause) { background-color: var(--transparent); box-shadow: none; @@ -423,11 +445,33 @@ .timeline .scrubber .head { fill: var(--blue); } .timeline .scrubber .needle { background-color: var(--blue); } +.timeline .scrubber .head, +.timeline .scrubber .needle { + transition-property: fill, background-color; + transition-duration: 150ms; +} + +.timeline.disabled .scrubberJumpArea { pointer-events: none; } +.timeline.disabled .scrubber .head { fill: var(--c600); } +.timeline.disabled .scrubber .needle { background-color: var(--c600); } + .timeline .labels .label { transform: translate(-50%, -100%); color: var(--c700); } +.timeline .labels .label, +.timeline .timeScale { + transition-property: color, opacity; + transition-duration: 150ms; +} + +.timeline.disabled .labels .label, +.timeline.disabled .timeScale { + color: var(--c600); + opacity: .6; +} + .timeline .scrubberJumpArea { height: 28px; z-index: 9; -- cgit v1.2.3