From e7e7f21510103394239f96bb3e398e5509a7533e Mon Sep 17 00:00:00 2001 From: andrewdkim Date: Mon, 1 Jul 2019 17:08:22 -0400 Subject: flyout --- src/client/views/nodes/Keyframe.tsx | 101 +++++++++++++---------------------- src/client/views/nodes/Timeline.scss | 36 +++++++++---- src/client/views/nodes/Timeline.tsx | 57 ++++++++++++-------- src/client/views/nodes/Track.tsx | 10 ++-- 4 files changed, 102 insertions(+), 102 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/Keyframe.tsx b/src/client/views/nodes/Keyframe.tsx index ed1f3b03a..263df0fd5 100644 --- a/src/client/views/nodes/Keyframe.tsx +++ b/src/client/views/nodes/Keyframe.tsx @@ -8,15 +8,19 @@ import { Doc, DocListCast } from "../../../new_fields/Doc"; import { Cast, FieldValue, StrCast, NumCast } from "../../../new_fields/Types"; import { List } from "../../../new_fields/List"; import { createSchema, defaultSpec, makeInterface, listSpec } from "../../../new_fields/Schema"; +import { any } from "bluebird"; +import { FlyoutProps } from "./Timeline"; +import { exportDefaultSpecifier } from "babel-types"; enum Direction { left = "left", right = "right" } + interface IProp { node: Doc; RegionData: Doc; - // routine: (innerFunc: () => void, args: any) => void; + setFlyout:(props:FlyoutProps) => any; } @@ -36,20 +40,6 @@ const RegionDataSchema = createSchema({ type RegionData = makeInterface<[typeof RegionDataSchema]>; export const RegionData = makeInterface(RegionDataSchema); -interface FlyoutInfo { - position: number; - fadeIn: number; - fadeOut: number; -} - - -const FlyoutObj = { - position: 0, - fadeIn: 0, - fadeOut: 1 -}; - -export var FlyoutInfoContext = React.createContext(FlyoutObj); @observer export class Keyframe extends React.Component { @@ -65,32 +55,12 @@ export class Keyframe extends React.Component { componentDidMount() { // need edge case here when keyframe data already exists when loading.....................; - this.fadein = 100; - - FlyoutInfoContext = React.createContext({position: this.position, - fadeIn: this.fadein, - fadeOut: this.fadeout}); } componentWillUnmount() { } - // @action - // onPointerEnter = (e: React.PointerEvent) => { - // e.preventDefault(); - // e.stopPropagation(); - // //this._display = "block"; - // } - - // @action - // onPointerOut = (e: React.PointerEvent) => { - // e.preventDefault(); - // e.stopPropagation(); - // //this._display = "none"; - // } - - @computed private get regiondata() { let index = this.regions.indexOf(this.props.RegionData); @@ -121,16 +91,31 @@ export class Keyframe extends React.Component { } - - @action onBarPointerDown = (e: React.PointerEvent) => { + let mouse = e.nativeEvent; + e.preventDefault(); e.stopPropagation(); - document.addEventListener("pointermove", this.onBarPointerMove); - document.addEventListener("pointerup", (e: PointerEvent) => { - document.removeEventListener("pointermove", this.onBarPointerMove); - }); + if (mouse.which === 1){ + document.addEventListener("pointermove", this.onBarPointerMove); + document.addEventListener("pointerup", (e: PointerEvent) => { + document.removeEventListener("pointermove", this.onBarPointerMove); + }); + } else if(mouse.which === 3) { + e.preventDefault(); + e.stopPropagation(); + let bar = this._bar.current!; + this.props.setFlyout({x:this.regiondata.position + 130, y: bar.getBoundingClientRect().bottom,display:"block", time: this.regiondata.position, duration:this.regiondata.duration}); + let removeFlyout = (e:PointerEvent) => { + if (e.which === 1){ + console.log("wut"); + this.props.setFlyout({display:"none"}); + document.removeEventListener("pointerdown", removeFlyout); + } + }; + document.addEventListener("pointerdown", removeFlyout); + } } @action @@ -138,7 +123,10 @@ export class Keyframe extends React.Component { e.preventDefault(); e.stopPropagation(); let left = this.findAdjacentRegion(Direction.left); - let right = this.findAdjacentRegion(Direction.right); + let right = this.findAdjacentRegion(Direction.right); + let bar = this._bar.current!; + let barX = bar.getBoundingClientRect().left; + let offset = e.clientX - barX; let futureX = this.regiondata.position + e.movementX; if (futureX <= 0) { this.regiondata.position = 0; @@ -149,7 +137,6 @@ export class Keyframe extends React.Component { } else { this.regiondata.position = futureX; } - } @action @@ -182,6 +169,7 @@ export class Keyframe extends React.Component { document.addEventListener("pointermove", this.onDragResizeLeft); document.addEventListener("pointerup", () => { document.removeEventListener("pointermove", this.onDragResizeLeft); + }); } @@ -192,6 +180,7 @@ export class Keyframe extends React.Component { document.addEventListener("pointermove", this.onDragResizeRight); document.addEventListener("pointerup", () => { document.removeEventListener("pointermove", this.onDragResizeRight); + }); } @@ -207,10 +196,7 @@ export class Keyframe extends React.Component { this.regiondata.keyframes!.forEach(kf => { kf = kf as Doc; kf.time = NumCast(kf.time) + offset; - }); - this._keyframes.forEach(num => { - num -= offset; - }); + }); } @@ -244,28 +230,14 @@ export class Keyframe extends React.Component { this.makeKeyData(position + mouse.offsetX); } - @action - onMenuHover = (e: React.PointerEvent) => { - e.preventDefault(); - e.stopPropagation(); - if (this._display === "none") { - this._display = "grid"; - } else { - this._display = "none"; - } - } - render() { return (
- -
+
{this.createDivider("left")}
@@ -279,7 +251,6 @@ export class Keyframe extends React.Component { {this.createDivider("left")} {this.createDivider("right")}
-
); } diff --git a/src/client/views/nodes/Timeline.scss b/src/client/views/nodes/Timeline.scss index d59ed1323..44b6cf03e 100644 --- a/src/client/views/nodes/Timeline.scss +++ b/src/client/views/nodes/Timeline.scss @@ -1,16 +1,32 @@ @import "./../globalCssVariables.scss"; -.flyout{ - position: absolute; - z-index: 9999; - background-color: black; - box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); - min-width: 150px; - color: black; - top: 100px; +.flyout-container{ + background-color: transparent; + position:absolute; + z-index:9999; + height: 150px; + width: 150px; - padding: 10px; - border-radius: 3px; + .flyout{ + background-color: transparent; + transform: rotate(180deg); + left:0px; + top:0px; + width: 100%; + height: 100%; + } + div{ + color: white; + position:absolute; + top:30px; + left:0px; + } + input{ + position:absolute; + width: 40px; + right:0px; + } + } .timeline-container{ diff --git a/src/client/views/nodes/Timeline.tsx b/src/client/views/nodes/Timeline.tsx index 02c2a530d..8050830fa 100644 --- a/src/client/views/nodes/Timeline.tsx +++ b/src/client/views/nodes/Timeline.tsx @@ -12,11 +12,18 @@ 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, faGripLines } from "@fortawesome/free-solid-svg-icons"; +import { faCircle, faPlayCircle, faBackward, faForward, faGripLines} from "@fortawesome/free-solid-svg-icons"; import { DocumentContentsView } from "./DocumentContentsView"; -import { FlyoutInfoContext } from "./Keyframe"; +export interface FlyoutProps{ + x?: number; + y?: number; + display?:string; + time?:number; + duration?:number; +} + @observer export class Timeline extends CollectionSubView(Document) { @@ -24,6 +31,7 @@ export class Timeline extends CollectionSubView(Document) { private readonly MIN_CONTAINER_HEIGHT: number = 205; private readonly MAX_CONTAINER_HEIGHT: number = 800; + @observable private _tickSpacing = 50; @observable private _scrubberbox = React.createRef(); @observable private _trackbox = React.createRef(); @@ -39,6 +47,7 @@ export class Timeline extends CollectionSubView(Document) { @observable private _infoContainer = React.createRef(); @observable private _ticks: number[] = []; + @observable private flyoutInfo:FlyoutProps = {x:0, y:0,display:"none"}; @action @@ -207,25 +216,35 @@ export class Timeline extends CollectionSubView(Document) { this._containerHeight = 0; } - renderFlyout = ():JSX.Element => { - // console.log("rendered"); - // let data = React.useContext(FlyoutInfoContext); - return ( -
-

- {/* {data.fadeIn} */} -

-
- ); + @action + getFlyout = (props: FlyoutProps) => { + for(const[k, v] of Object.entries(props)){ + (this.flyoutInfo as any)[k] = v; + } + } - + + @action + onFlyoutDown = (e: React.PointerEvent) => { + console.log("clicked!"); + this.flyoutInfo.display = "block"; + } render() { return (
+
+ +
+

Time:

+

Duration:

+

Fade-in

+

Fade-out

+
+
@@ -239,7 +258,7 @@ export class Timeline extends CollectionSubView(Document) {
{this._ticks.map(element => { - return

{this.toTime(element)}

; + return

{this.toTime(element)}

; })}
@@ -247,7 +266,7 @@ export class Timeline extends CollectionSubView(Document) {
{this._nodes.map(doc => { - return ; + return ; })}
@@ -261,14 +280,6 @@ export class Timeline extends CollectionSubView(Document) {
- - {value => ( -
-

- {value.fadeIn} -

-
)} -
); } diff --git a/src/client/views/nodes/Track.tsx b/src/client/views/nodes/Track.tsx index 957128040..94c0b5563 100644 --- a/src/client/views/nodes/Track.tsx +++ b/src/client/views/nodes/Track.tsx @@ -7,15 +7,17 @@ import { Document, listSpec, createSchema, makeInterface, defaultSpec } from ".. import { FieldValue, Cast, NumCast, BoolCast } from "../../../new_fields/Types"; import { List } from "../../../new_fields/List"; import { Keyframe, RegionData } from "./Keyframe"; +import { FlyoutProps } from "./Timeline"; -interface IProp { +interface IProps { node: Doc; currentBarX: number; - // setPosition: (position: number) => any; + setFlyout: (props:FlyoutProps) => any; } + @observer -export class Track extends React.Component { +export class Track extends React.Component { @observable private _inner = React.createRef(); private _reactionDisposers: IReactionDisposer[] = []; @@ -196,7 +198,7 @@ export class Track extends React.Component {
{this.regions.map((region) => { - return ; + return ; })}
-- cgit v1.2.3-70-g09d2