From 4f1acae3f4a87acc91e05d7d46fb33278c08292b Mon Sep 17 00:00:00 2001 From: andrewdkim Date: Fri, 12 Jul 2019 16:48:07 -0400 Subject: Fixed Bugs, Timeline Movement, improved interpolation, organization --- src/client/views/nodes/Timeline.tsx | 71 +++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 27 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 a9add619c..ee33245af 100644 --- a/src/client/views/nodes/Timeline.tsx +++ b/src/client/views/nodes/Timeline.tsx @@ -16,6 +16,8 @@ import { DocumentContentsView } from "./DocumentContentsView"; import { ContextMenuProps } from "../ContextMenuItem"; import { ContextMenu } from "../ContextMenu"; import { string } from "prop-types"; +import { checkIfStateModificationsAreAllowed } from "mobx/lib/internal"; +import { SelectorContextMenu } from "../collections/ParentDocumentSelector"; export interface FlyoutProps { @@ -46,6 +48,7 @@ export class Timeline extends CollectionSubView(Document) { @observable private _durationInput = React.createRef(); @observable private _fadeInInput = React.createRef(); @observable private _fadeOutInput = React.createRef(); + @observable private _timelineWrapper = React.createRef(); @observable private _currentBarX: number = 0; @@ -62,8 +65,8 @@ export class Timeline extends CollectionSubView(Document) { @observable private flyoutInfo: FlyoutProps = { x: 0, y: 0, display: "none", regiondata: new Doc(), regions: new List() }; private block = false; - componentWillMount() { - console.log(this._ticks.length ); + componentWillMount() { + console.log(this._ticks.length); runInAction(() => { //check if this is a video frame for (let i = 0; i < this._time;) { @@ -72,14 +75,15 @@ export class Timeline extends CollectionSubView(Document) { } }); } - componentDidMount() { - runInAction(() => {let children = Cast(this.props.Document[this.props.fieldKey], listSpec(Doc)); + componentDidMount() { + runInAction(() => { + let children = Cast(this.props.Document[this.props.fieldKey], listSpec(Doc)); if (!children) { return; } - let childrenList = ((children[Self] as any).__fields) as List; - this._nodes = (childrenList) as List; - }); + let childrenList = children; + this._nodes = childrenList; + }); this.initialize(); } @@ -95,7 +99,7 @@ export class Timeline extends CollectionSubView(Document) { initialize = action(() => { let scrubber = this._scrubberbox.current!; this._boxLength = scrubber.getBoundingClientRect().width; - + reaction(() => this._time, time => { let infoContainer = this._infoContainer.current!; @@ -217,7 +221,7 @@ export class Timeline extends CollectionSubView(Document) { titleContainer.scrollTop = titleContainer.scrollTop - e.movementY; } - + @action onResizeDown = (e: React.PointerEvent) => { e.preventDefault(); @@ -245,19 +249,23 @@ export class Timeline extends CollectionSubView(Document) { @action onTimelineDown = (e: React.PointerEvent) => { e.preventDefault(); - e.stopPropagation(); - document.addEventListener("pointermove", this.onTimelineMove); - document.addEventListener("pointerup", () => { document.removeEventListener("pointermove", this.onTimelineMove); }); + //e.stopPropagation(); + if (e.nativeEvent.which === 1){ + document.addEventListener("pointermove", this.onTimelineMove); + document.addEventListener("pointerup", () => { document.removeEventListener("pointermove", this.onTimelineMove);}); + } } @action onTimelineMove = (e: PointerEvent) => { e.preventDefault(); e.stopPropagation(); - let timelineContainer = this._timelineContainer.current!; - timelineContainer.style.transform = `translate(${timelineContainer.getBoundingClientRect().left + 1}px, ${timelineContainer.getBoundingClientRect().top + 1}px)`; - console.log("mouse move!"); - timelineContainer.style.width = "500px"; + let timelineContainer = this._timelineWrapper.current!; + let left = parseFloat(timelineContainer.style.left!); + let top = parseFloat(timelineContainer.style.top!); + timelineContainer.style.left = `${left + e.movementX}px`; + timelineContainer.style.top = `${top + e.movementY}px`; + this.setPlacementHighlight(0, 0, 1000, 1000); // do something with setting the placement highlighting } @action @@ -296,15 +304,22 @@ export class Timeline extends CollectionSubView(Document) { timelineContextMenu = (e: React.MouseEvent): void => { let subitems: ContextMenuProps[] = []; - let timelineContainer = this._timelineContainer.current!; - subitems.push({ description: "Pin to Top", event: action(() => { timelineContainer.style.transform = "translate(0px, 0px)"; }), icon: "pinterest" }); + let timelineContainer = this._timelineWrapper.current!; + subitems.push({ description: "Pin to Top", event: action(() => { + timelineContainer.style.transition = "top 1000ms ease-in, left 1000ms ease-in"; //????? + timelineContainer.style.left = "0px"; + timelineContainer.style.top = "0px"; + timelineContainer.style.transition = "none"; + + + }), icon: "pinterest" }); subitems.push({ description: "Pin to Bottom", event: action(() => { + console.log(timelineContainer.getBoundingClientRect().bottom); timelineContainer.style.transform = `translate(0px, ${e.pageY - this._containerHeight}px)`; }), icon: "pinterest" }); ContextMenu.Instance.addItem({ description: "Timeline Funcs...", subitems: subitems }); - } @action @@ -355,10 +370,14 @@ export class Timeline extends CollectionSubView(Document) { } } } + private setPlacementHighlight = (x = 0, y = 0, height:(string| number) = 0, width:(string | number) = 0):JSX.Element => { + return
; + } render() { return ( -
+
+ {this.setPlacementHighlight(0,0,300,400)}
@@ -373,11 +392,10 @@ export class Timeline extends CollectionSubView(Document) { -
-
+
@@ -388,7 +406,6 @@ export class Timeline extends CollectionSubView(Document) {
*/}
-
{this._ticks.map(element => { return

{this.toTime(element)}

; @@ -398,15 +415,15 @@ export class Timeline extends CollectionSubView(Document) {
- {this._nodes.map(doc => { - return ; + {DocListCast(this._nodes).map(doc => { + return ; })}
- {this._nodes.map(doc => { + {DocListCast(this._nodes).map(doc => { return
-

{((doc as any).value() as Doc).title}

+

{doc.title}

; })}
-- cgit v1.2.3-70-g09d2