From 3b3695cfc5674a93c0ecee4d2af5d8ba8c8cfb70 Mon Sep 17 00:00:00 2001 From: mehekj Date: Sun, 5 Jun 2022 12:02:24 -0400 Subject: fade full screen controls --- src/client/views/nodes/VideoBox.scss | 11 ++-------- src/client/views/nodes/VideoBox.tsx | 39 ++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/VideoBox.scss b/src/client/views/nodes/VideoBox.scss index 1fb5cef98..b97e90bd9 100644 --- a/src/client/views/nodes/VideoBox.scss +++ b/src/client/views/nodes/VideoBox.scss @@ -86,15 +86,13 @@ align-items: center; justify-content: center; display: flex; - // visibility: none; - // opacity: 0; background-color: $dark-gray; color: white; border-radius: 100px; z-index: 2001; min-width: 300px; - transition: top 0.5s, width 0.5s, opacity 0.2s, visibility 0s; + transition: top 0.5s, width 0.5s, opacity 0.2s, visibility 0.2s; height: 50px; padding: 0 10px 0 7px; @@ -161,16 +159,11 @@ align-items: flex-end; .videoBox-ui { - // opacity: 0; left: 50%; top: 90%; transform: translate(-50%, -50%); width: 80%; - transition: none; - } - - .videoBox-ui:hover { - opacity: 1; + transition: top 0s, width 0s, opacity 0.3s, visibility 0.3s; } } diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx index 3ffd813d6..a98cd8cf4 100644 --- a/src/client/views/nodes/VideoBox.tsx +++ b/src/client/views/nodes/VideoBox.tsx @@ -4,7 +4,7 @@ import { action, computed, IReactionDisposer, observable, ObservableMap, reactio import { observer } from "mobx-react"; import { basename } from "path"; import * as rp from 'request-promise'; -import { Doc, DocListCast, HeightSym, WidthSym } from "../../../fields/Doc"; +import { Doc, DocListCast, HeightSym, Opt, WidthSym } from "../../../fields/Doc"; import { InkTool } from "../../../fields/InkField"; import { Cast, NumCast, StrCast } from "../../../fields/Types"; import { AudioField, ImageField, VideoField } from "../../../fields/URLField"; @@ -84,6 +84,10 @@ export class VideoBox extends ViewBoxAnnotatableComponent = React.createRef(); // outermost div private _annotationLayer: React.RefObject = React.createRef(); private _playRegionTimer: any = null; // timeout for playback + private _controlsFadeTimer: any = null; // timeout for controls fade + + public onMakeAnchor: () => Opt = () => undefined; // Method to get anchor from text search + @observable _stackedTimeline: any; // CollectionStackedTimeline ref @observable static _nativeControls: boolean; // default html controls @observable _marqueeing: number[] | undefined; // coords for marquee selection @@ -98,6 +102,7 @@ export class VideoBox extends ViewBoxAnnotatableComponent { + e.stopPropagation(); + this._controlsVisible = true; + clearTimeout(this._controlsFadeTimer); + this._controlsFadeTimer = setTimeout(action(() => this._controlsVisible = false), 3000); + } + + // drag controls around window in fulls screen @action controlsDrag = (e: React.PointerEvent) => { e.preventDefault(); e.stopPropagation(); @@ -361,7 +374,19 @@ export class VideoBox extends ViewBoxAnnotatableComponent { this._contentRef = cref; if (cref) { - cref.onfullscreenchange = action((e) => this._fullScreen = (document.fullscreenElement === cref)); + cref.onfullscreenchange = action((e) => { + this._fullScreen = (document.fullscreenElement === cref); + if (this._fullScreen) { + document.addEventListener('pointermove', this.controlsFade); + this._controlsVisible = true; + this._controlsFadeTimer = setTimeout(action(() => this._controlsVisible = false), 3000) + console.log("added"); + } + else { + document.removeEventListener('pointermove', this.controlsFade); + console.log("removed"); + } + }); } } @@ -402,9 +427,10 @@ export class VideoBox extends ViewBoxAnnotatableComponentLoading : -
+
this._fullScreen && e.stopPropagation()}> - {this._fullScreen &&
+ {this._fullScreen &&
{this.UIButtons}
} @@ -830,6 +856,7 @@ export class VideoBox extends ViewBoxAnnotatableComponent
; } -- cgit v1.2.3-70-g09d2