From af42d3061bd85907e3d987f0d794c250cfaded1c Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 3 Jan 2024 09:33:01 -0500 Subject: from last --- src/client/views/nodes/DataVizBox/DataVizBox.tsx | 21 ++++++++++----------- src/client/views/nodes/VideoBox.tsx | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx index 12e8e1a69..ff0e3271d 100644 --- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx +++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx @@ -3,7 +3,7 @@ import { Colors, Toggle, ToggleType, Type } from 'browndash-components'; import { ObservableMap, action, computed, observable, runInAction } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; -import { emptyFunction, returnEmptyString, returnFalse, setupMoveUpEvents } from '../../../../Utils'; +import { emptyFunction, returnEmptyString, returnFalse, returnOne, setupMoveUpEvents } from '../../../../Utils'; import { Doc, DocListCast, Field, Opt, StrListCast } from '../../../../fields/Doc'; import { InkTool } from '../../../../fields/InkField'; import { List } from '../../../../fields/List'; @@ -38,9 +38,9 @@ export enum DataVizView { @observer export class DataVizBox extends ViewBoxAnnotatableComponent() { - private _getAnchor: (savedAnnotations: Opt>, addAsAnnotation: boolean) => Opt = () => undefined; private _mainCont: React.RefObject = React.createRef(); private _ffref = React.createRef(); + private _marqueeref = React.createRef(); private _annotationLayer: React.RefObject = React.createRef(); anchorMenuClick?: () => undefined | ((anchor: Doc) => void); crop: ((region: Doc | undefined, addCrop?: boolean) => Doc | undefined) | undefined; @@ -58,8 +58,7 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { e, action(e => { MarqueeAnnotator.clearAnnotations(this._savedAnnotations); - //this._marqueeing = [e.pageX, e.pageY]; - this._marqueeing = [e.clientX, e.clientY]; + this._marqueeref.current?.onInitiateSelection([e.clientX, e.clientY]); return true; }), returnFalse, @@ -70,8 +69,7 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { }; @action finishMarquee = () => { - this._getAnchor = AnchorMenu.Instance?.GetAnchor; - this._marqueeing = undefined; + this._marqueeref.current?.onTerminateSelection(); this._props.select(false); }; savedAnnotations = () => this._savedAnnotations; @@ -125,8 +123,8 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { } return func() ?? false; }; - getAnchor = (addAsAnnotation?: boolean, pinProps?: PinProps) => { - const visibleAnchor = this._getAnchor?.(this._savedAnnotations, false); // use marquee anchor, otherwise, save zoom/pan as anchor + getAnchor = (addAsAnnotation: boolean, pinProps?: PinProps) => { + const visibleAnchor = AnchorMenu.Instance.GetAnchor?.(undefined, addAsAnnotation); const anchor = !pinProps ? this.Document : this._vizRenderer?.getAnchor(pinProps) ?? @@ -413,15 +411,16 @@ export class DataVizBox extends ViewBoxAnnotatableComponent() { {this.sidebarHandle} {this.annotationLayer} - {!this._marqueeing || !this._mainCont.current || !this._annotationLayer.current ? null : ( + {!this._mainCont.current || !this._annotationLayer.current ? null : ( () { +export class VideoBox extends ViewBoxAnnotatableComponent() { public static LayoutString(fieldKey: string) { return FieldView.LayoutString(VideoBox, fieldKey); } -- cgit v1.2.3-70-g09d2