From 5a3bec8422a078a1c66f84587bd4de5e200f8caf Mon Sep 17 00:00:00 2001 From: mehekj Date: Tue, 21 Jun 2022 13:33:45 -0400 Subject: fades when scrub with arrow keys and cleaner transition --- src/client/views/nodes/VideoBox.tsx | 48 +++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx index bad7813ef..43f052859 100644 --- a/src/client/views/nodes/VideoBox.tsx +++ b/src/client/views/nodes/VideoBox.tsx @@ -29,8 +29,8 @@ import { MarqueeAnnotator } from "../MarqueeAnnotator"; import { AnchorMenu } from "../pdf/AnchorMenu"; import { StyleProp } from "../StyleProvider"; import { FieldView, FieldViewProps } from './FieldView'; -import "./VideoBox.scss"; import { RecordingBox } from "./RecordingBox/RecordingBox"; +import "./VideoBox.scss"; const path = require('path'); /** @@ -103,7 +103,8 @@ export class VideoBox extends ViewBoxAnnotatableComponent this._disposers[d]?.()); + document.removeEventListener("keydown", this.keyEvents, true); } + // handles key events, when timeline scrubs fade controls + @action + keyEvents = (e: KeyboardEvent) => { + if ( + !(e.target instanceof HTMLInputElement) && + this.props.isSelected(true) + ) { + switch (e.key) { + case "ArrowLeft": + case "ArrowRight": + clearTimeout(this._controlsFadeTimer); + this._scrubbing = true; + this._controlsFadeTimer = setTimeout(action(() => this._scrubbing = false), 500); + e.stopPropagation(); + break; + } + } + } // plays video @action public Play = (update: boolean = true) => { @@ -168,11 +189,11 @@ export class VideoBox extends ViewBoxAnnotatableComponent { e.stopPropagation(); clearTimeout(this._controlsFadeTimer); - this._controlsFadeTimer = setTimeout(action(() => this._controlsOpacity = 0), 3000); + this._controlsVisible = true; + this._scrubbing = false; + this._controlsFadeTimer = setTimeout(action(() => this._controlsVisible = false), 3000); } @@ -446,6 +469,9 @@ export class VideoBox extends ViewBoxAnnotatableComponent { this._fullScreen = (document.fullscreenElement === cref); + this._controlsVisible = true; + this._scrubbing = false; + clearTimeout(this._controlsFadeTimer); if (this._fullScreen) { document.addEventListener('pointermove', this.controlsFade); } @@ -505,11 +531,12 @@ export class VideoBox extends ViewBoxAnnotatableComponentLoading : -
+
this._fullScreen && e.stopPropagation()}> {this._fullScreen &&
+ style={{ left: this._controlsTransform && this._controlsTransform.X, top: this._controlsTransform && this._controlsTransform.Y, visibility: this._controlsVisible || this._scrubbing ? 'visible' : 'hidden', opacity: opacity }}> {this.UIButtons}
}