From 545508987903be8c2f361bbee8b3beae683c73b5 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 26 Oct 2023 23:23:48 -0400 Subject: a variety of fixes to the animation timeline to make it make some sense. lots still broken. --- .../views/animationtimeline/TimelineMenu.tsx | 100 +++++++++++++-------- 1 file changed, 61 insertions(+), 39 deletions(-) (limited to 'src/client/views/animationtimeline/TimelineMenu.tsx') diff --git a/src/client/views/animationtimeline/TimelineMenu.tsx b/src/client/views/animationtimeline/TimelineMenu.tsx index aa422c092..1769c41bd 100644 --- a/src/client/views/animationtimeline/TimelineMenu.tsx +++ b/src/client/views/animationtimeline/TimelineMenu.tsx @@ -1,12 +1,11 @@ -import * as React from "react"; -import { observable, action, runInAction } from "mobx"; -import { observer } from "mobx-react"; -import "./TimelineMenu.scss"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faChartLine, faRoad, faClipboard, faPen, faTrash, faTable } from "@fortawesome/free-solid-svg-icons"; -import { Utils } from "../../../Utils"; -import { IconLookup } from "@fortawesome/fontawesome-svg-core"; - +import { IconLookup } from '@fortawesome/fontawesome-svg-core'; +import { faChartLine, faClipboard } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { action, observable } from 'mobx'; +import { observer } from 'mobx-react'; +import * as React from 'react'; +import { Utils } from '../../../Utils'; +import './TimelineMenu.scss'; @observer export class TimelineMenu extends React.Component { @@ -25,9 +24,9 @@ export class TimelineMenu extends React.Component { @action openMenu = (x?: number, y?: number) => { this._opacity = 1; - x ? this._x = x : this._x = 0; - y ? this._y = y : this._y = 0; - } + x ? (this._x = x) : (this._x = 0); + y ? (this._y = y) : (this._y = 0); + }; @action closeMenu = () => { @@ -35,44 +34,67 @@ export class TimelineMenu extends React.Component { this._currentMenu = []; this._x = -1000000; this._y = -1000000; - } + }; @action - addItem = (type: "input" | "button", title: string, event: (e: any, ...args: any[]) => void) => { - if (type === "input") { + addItem = (type: 'input' | 'button', title: string, event: (e: any, ...args: any[]) => void) => { + if (type === 'input') { const inputRef = React.createRef(); - let text = ""; - this._currentMenu.push(
{ - e.stopPropagation(); - text = e.target.value; - }} onKeyDown={(e) => { - if (e.keyCode === 13) { - event(text); - this.closeMenu(); - e.stopPropagation(); - } - }} />
); - } else if (type === "button") { - this._currentMenu.push(

{ - e.preventDefault(); - e.stopPropagation(); - event(e); - this.closeMenu(); - }}>{title}

); + let text = ''; + this._currentMenu.push( +
+ + { + e.stopPropagation(); + text = e.target.value; + }} + onKeyDown={e => { + if (e.keyCode === 13) { + event(Number(text)); + this.closeMenu(); + e.stopPropagation(); + } + }} + /> +
+ ); + } else if (type === 'button') { + this._currentMenu.push( +
+ +

{ + e.preventDefault(); + e.stopPropagation(); + event(e); + this.closeMenu(); + }}> + {title} +

+
+ ); } - } + }; @action addMenu = (title: string) => { - this._currentMenu.unshift(

{title}

); - } + this._currentMenu.unshift( +
+

{title}

+
+ ); + }; render() { return ( -
+
{this._currentMenu}
); } - -} \ No newline at end of file +} -- cgit v1.2.3-70-g09d2