From 469838fd9c6515c0ec1894e5964be51e8a8b988b Mon Sep 17 00:00:00 2001 From: mehekj Date: Tue, 7 Jun 2022 12:06:45 -0400 Subject: dynamically adjust video controls based on scale --- src/client/views/nodes/VideoBox.scss | 11 +++--- src/client/views/nodes/VideoBox.tsx | 72 +++++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/VideoBox.scss b/src/client/views/nodes/VideoBox.scss index f279b9709..47867b128 100644 --- a/src/client/views/nodes/VideoBox.scss +++ b/src/client/views/nodes/VideoBox.scss @@ -95,8 +95,7 @@ color: white; border-radius: 100px; z-index: 2001; - min-width: 300px; - height: 50px; + height: 40px; padding: 0 10px 0 7px; .timecode-controls { @@ -121,8 +120,8 @@ .videobox-button { margin: 2px; cursor: pointer; - width: 30px; - height: 30px; + width: 25px; + height: 25px; border-radius: 50%; background: $dark-gray; display: flex; @@ -134,8 +133,8 @@ } svg { - width: 17px; - height: 17px; + width: 15px; + height: 15px; } } } diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx index 76b1ad842..61afda70f 100644 --- a/src/client/views/nodes/VideoBox.tsx +++ b/src/client/views/nodes/VideoBox.tsx @@ -763,17 +763,22 @@ export class VideoBox extends ViewBoxAnnotatableComponent -
+ const width = right - left; + const uiHeight = Math.max(25, Math.min(50, height / 10)); + const uiMargin = Math.min(10, height / 20); + const vidHeight = height * this.heightPercent / 100; + const yPos = top + vidHeight - uiHeight - uiMargin; + const xPos = uiHeight / vidHeight > 0.5 ? right + 10 : left + 10; + return this._fullScreen || width < 50 ? null :
+
{this.UIButtons}
} @computed get UIButtons() { + const bounds = this.props.docViewPath().lastElement().getBounds(); + const width = (bounds?.right || 0) - (bounds?.left || 0); const curTime = NumCast(this.layoutDoc._currentTimecode) - (this.timeline?.clipStart || 0); return <>
- {this.timeline &&
+ {this.timeline && width > 160 &&
{formatTime(curTime)}
- {this._fullScreen || this.heightPercent === 100 ? + {this._fullScreen || (this.heightPercent === 100 && width > 200) ?
{formatTime(this.timeline.clipDuration)}
-
} +
+ } -
100 &&
-
- - {!this._fullScreen &&
-
} - {!this._fullScreen &&
- -
} + { + !this._fullScreen && width > 250 &&
+ +
+ } -
250 &&
+ +
+ } + + {width > 70 &&
{ e.stopPropagation(); this.toggleMute(); }}> -
- e.stopPropagation()} - onChange={(e: React.ChangeEvent) => this.setVolume(Number(e.target.value))} - /> +
} + { + width > 300 && e.stopPropagation()} + onChange={(e: React.ChangeEvent) => this.setVolume(Number(e.target.value))} + /> + } - {!this._fullScreen && this.heightPercent !== 100 && + { + !this._fullScreen && this.heightPercent !== 100 && width > 300 && <>
@@ -842,7 +855,8 @@ export class VideoBox extends ViewBoxAnnotatableComponent { e.stopPropagation(); }} onChange={(e: React.ChangeEvent) => { this.zoom(Number(e.target.value)); }} /> - } + + } } -- cgit v1.2.3-70-g09d2