From 9501e39728851d7cd66faa51c619e17b0265f56e Mon Sep 17 00:00:00 2001 From: mehekj Date: Wed, 8 Jun 2022 15:51:28 -0400 Subject: thumbnail preview of video when hovering over timeline --- .../collections/CollectionStackedTimeline.scss | 30 ++++++++++++++++-- .../collections/CollectionStackedTimeline.tsx | 36 ++++++++++++++++++++-- 2 files changed, 61 insertions(+), 5 deletions(-) (limited to 'src/client/views/collections') diff --git a/src/client/views/collections/CollectionStackedTimeline.scss b/src/client/views/collections/CollectionStackedTimeline.scss index e8b6817b4..580cbccda 100644 --- a/src/client/views/collections/CollectionStackedTimeline.scss +++ b/src/client/views/collections/CollectionStackedTimeline.scss @@ -8,6 +8,16 @@ background-color: $white; border: 2px solid $dark-gray; border-width: 0 2px 0 2px; + + &:hover { + .collectionStackedTimeline-hover { + display: block; + } + } +} + +.timeline-container:hover + .videoBox-thumbnail { + display: block; } ::-webkit-scrollbar { @@ -61,15 +71,23 @@ border-width: 1px; } - .collectionStackedTimeline-current { + .collectionStackedTimeline-current, .collectionStackedTimeline-hover { width: 1px; height: 100%; - background-color: $pink; position: absolute; top: 0px; pointer-events: none; } + .collectionStackedTimeline-current { + background-color: $pink; + } + + .collectionStackedTimeline-hover { + display: none; + background-color: $medium-blue; + } + .collectionStackedTimeline-marker-timeline { position: absolute; top: 2.5%; @@ -108,3 +126,11 @@ pointer-events: none; } } + +.videoBox-thumbnail { + position: absolute; + z-index: 10000; + transform: translate(-50%, 100%); + height: 100%; + display: none; +} \ No newline at end of file diff --git a/src/client/views/collections/CollectionStackedTimeline.tsx b/src/client/views/collections/CollectionStackedTimeline.tsx index ca0b9d3d3..2b78f5764 100644 --- a/src/client/views/collections/CollectionStackedTimeline.tsx +++ b/src/client/views/collections/CollectionStackedTimeline.tsx @@ -43,6 +43,8 @@ import { } from "../nodes/DocumentView"; import { LabelBox } from "../nodes/LabelBox"; import "./CollectionStackedTimeline.scss"; +import { VideoBox } from "../nodes/VideoBox"; +import { ImageField } from "../../../fields/URLField"; export type CollectionStackedTimelineProps = { Play: () => void; @@ -86,9 +88,12 @@ export class CollectionStackedTimeline extends CollectionSubView { + e.stopPropagation(); + const rect = this._timeline?.getBoundingClientRect(); + const clientX = e.clientX; + if (rect) { + this._hoverTime = Math.min(this.toTimeline(clientX - rect.x, rect.width), this.clipEnd); + if (this.dataDoc.thumbnails) { + const nearest = Math.floor(this._hoverTime / this.props.rawDuration * VideoBox.numThumbnails); + const thumbnails = Cast(this.dataDoc.thumbnails, listSpec("string"), []); + const src = new ImageField(thumbnails[nearest]).url.href.replace(".png", "_s.png"); + this._thumbnail = src; + console.log(src); + } + } + } + + // for dragging trim start handle @action trimLeft = (e: React.PointerEvent): void => { const rect = this._timeline?.getBoundingClientRect(); - const clientX = e.movementX; setupMoveUpEvents( this, e, @@ -346,7 +368,6 @@ export class CollectionStackedTimeline extends CollectionSubView { const rect = this._timeline?.getBoundingClientRect(); - const clientX = e.movementX; setupMoveUpEvents( this, e, @@ -631,6 +652,7 @@ export class CollectionStackedTimeline extends CollectionSubView e.stopPropagation()} onScroll={this.setScroll} + onMouseMove={(e) => this.isContentActive() && this.onHover(e)} ref={wrapper => this._timelineWrapper = wrapper}>
{/* {this.renderDictation} */} +
+
+ {this._thumbnail && }
); } } -- cgit v1.2.3-70-g09d2