From df5c4abc3acbf67db44384ef000c893c61270fcc Mon Sep 17 00:00:00 2001 From: andrewdkim Date: Fri, 21 Jun 2019 17:32:45 -0400 Subject: tick marks --- src/client/views/nodes/Timeline.tsx | 74 +++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 7 deletions(-) (limited to 'src/client/views/nodes/Timeline.tsx') diff --git a/src/client/views/nodes/Timeline.tsx b/src/client/views/nodes/Timeline.tsx index c6118da91..c0f34ace5 100644 --- a/src/client/views/nodes/Timeline.tsx +++ b/src/client/views/nodes/Timeline.tsx @@ -11,6 +11,10 @@ import { SelectionManager } from "../../util/SelectionManager"; import { List } from "../../../new_fields/List"; import { Self } from "../../../new_fields/FieldSymbols"; import { Doc, DocListCast } from "../../../new_fields/Doc"; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faCircle, faPlayCircle, faBackward, faForward } from "@fortawesome/free-solid-svg-icons"; + + @observer export class Timeline extends CollectionSubView(Document){ @@ -21,8 +25,9 @@ export class Timeline extends CollectionSubView(Document){ @observable private _isPlaying:boolean = false; @observable private _boxLength:number = 0; @observable private _nodes:List = new List(); - + @observable private _time = 100000; //DEFAULT + @observable private _ticks: number[] = []; private _reactionDisposers: IReactionDisposer[] = []; @@ -36,12 +41,26 @@ export class Timeline extends CollectionSubView(Document){ } let childrenList = ((children[Self] as any).__fields) as List; this._nodes = (childrenList) as List; + + + //check if this is a video frame + + let boxWidth = scrubber.getBoundingClientRect().width; + for (let i = 0; i < this._time; ) { + this._ticks.push(i); + i += 1000; + } + } componentWillUnmount(){ } + + + + //for playing @action onPlay = async (e: React.MouseEvent) => { if (this._isPlaying) { @@ -77,28 +96,69 @@ export class Timeline extends CollectionSubView(Document){ } } + //for scrubber action @action onScrubberDown = (e:React.PointerEvent) => { + e.preventDefault(); + e.stopPropagation(); + let scrubberbox = this._scrubberbox.current!; + //let left = scrubberbox.getBoundingClientRect().left; + + //let offsetX = Math.round(e.clientX - left); + let mouse = e.nativeEvent; + this._currentBarX = mouse.offsetX; + document.addEventListener("pointermove", this.onScrubberMove); + document.addEventListener("pointerup", this.onScrubberFinished); + } + + @action + onScrubberMove = (e: PointerEvent) => { + e.preventDefault(); + e.stopPropagation(); let scrubberbox = this._scrubberbox.current!; let left = scrubberbox.getBoundingClientRect().left; let offsetX = Math.round(e.clientX - left); this._currentBarX = offsetX; } + onScrubberFinished = (e: PointerEvent) => { + e.preventDefault(); + e.stopPropagation(); + let scrubberbox = this._scrubberbox.current!; + document.removeEventListener("pointermove", this.onScrubberMove); + } + + toTime = (time:number):string => { + const inSeconds = time / 1000; + let min:(string|number) = Math.floor(inSeconds / 60); + let sec:(string|number) = inSeconds % 60; + + if (Math.floor(sec/10) === 0){ + sec = "0" + sec; + } + return `${min}:${sec}`; + + } + render(){ return (
- - - +
+
+
-
-
+
+
+ {this._ticks.map(element => {return

{this.toTime(element)}

})} + +
+
+ ;
- {this._nodes.map(doc => {return })} + {this._nodes.map(doc => {return ;})}
); -- cgit v1.2.3-70-g09d2