From 373065dc43fb26791d35cb1e9f521258de192a85 Mon Sep 17 00:00:00 2001 From: zevav Date: Fri, 2 Oct 2020 22:20:42 +0200 Subject: [PATCH] added a modifier to ffwd/rewind (ctrl) to take bigger steps. made progress bar clickable. added duration to modules --- modulearn/src/App.svelte | 39 +++++++++++++++++++----------------- modulearn/src/Module.svelte | 22 +++++++++++++++++--- modulearn/src/Modules.svelte | 2 +- modulearn/src/data.js | 5 +++-- 4 files changed, 44 insertions(+), 24 deletions(-) diff --git a/modulearn/src/App.svelte b/modulearn/src/App.svelte index 84856cf..d00e437 100644 --- a/modulearn/src/App.svelte +++ b/modulearn/src/App.svelte @@ -33,6 +33,13 @@ } } + const onRepositionInModule = event => { + const { percentage } = event.detail + const pos = $currentModule.start + ($currentModule.duration * percentage / 100) + console.log(pos) + jumpTo(pos) + } + onMount(() => positionUpdater()) const toggle = video => { @@ -43,12 +50,18 @@ } } + const jumpTo = pos => { + clearInterval(interval) + video.jumpTo(pos) + positionUpdater() + } + const handleKeyDown = e => { - const { key, code, ctrlKey } = e - if (e.shiftKey || e.altKey || e.metaKey) { - return - } - let amount = 5 + const { key, code, ctrlKey, shiftKey, altKey, metaKey } = e + + if (shiftKey || altKey || metaKey) return + + const amount = ctrlKey ? 30 : 5 if (["j", "ArrowDown"].includes(key)) { e.preventDefault() nextModule() @@ -60,20 +73,10 @@ toggle(video) } else if (["l", "ArrowRight"].includes(key)) { e.preventDefault() - clearInterval(interval) - if (ctrlKey) { - amount = 30 - } - video.jumpTo($position + amount) - positionUpdater() + jumpTo($position + amount) } else if (["h", "ArrowLeft"].includes(key)) { e.preventDefault() - clearInterval(interval) - if (ctrlKey) { - amount = 30 - } - video.jumpTo($position - amount) - positionUpdater() + jumpTo($position - amount) } } @@ -104,7 +107,7 @@
- +