From 0fbfb06c499d2ee52b086427cbf1c5431fadfad9 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 16 Dec 2020 21:39:47 -0500 Subject: simplified DocumentView a bit more. cleaned up other code. --- src/Utils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Utils.ts') diff --git a/src/Utils.ts b/src/Utils.ts index 1a00c0bfb..852a00406 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -592,6 +592,14 @@ export function lightOrDark(color: any) { } } +export function isTarget(x: number, y: number, target: HTMLDivElement | null) { + let entered = false; + for (let child = document.elementFromPoint(x, y); !entered && child; child = child.parentElement) { + entered = entered || child === target; + } + return entered; +} + export function setupMoveUpEvents( target: object, e: React.PointerEvent, -- cgit v1.2.3-70-g09d2 From f4f4cb6b3a639c3e1c0d291f1d290e80097cfa06 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 16 Dec 2020 23:30:57 -0500 Subject: fixed unbrushing docs --- src/Utils.ts | 2 +- src/client/views/nodes/DocumentView.tsx | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/Utils.ts') diff --git a/src/Utils.ts b/src/Utils.ts index 852a00406..f160df6f7 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -592,7 +592,7 @@ export function lightOrDark(color: any) { } } -export function isTarget(x: number, y: number, target: HTMLDivElement | null) { +export function hasDescendantTarget(x: number, y: number, target: HTMLDivElement | null) { let entered = false; for (let child = document.elementFromPoint(x, y); !entered && child; child = child.parentElement) { entered = entered || child === target; diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index b9ca460b9..e99b0a155 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -9,8 +9,7 @@ import { ScriptField } from '../../../fields/ScriptField'; import { BoolCast, Cast, NumCast, ScriptCast, StrCast } from "../../../fields/Types"; import { GetEffectiveAcl, TraceMobx } from '../../../fields/util'; import { MobileInterface } from '../../../mobile/MobileInterface'; -import { GestureUtils } from '../../../pen-gestures/GestureUtils'; -import { emptyFunction, isTarget as hasDescendantTarget, OmitKeys, returnFalse, returnVal, Utils } from "../../../Utils"; +import { emptyFunction, hasDescendantTarget, OmitKeys, returnFalse, returnVal, Utils } from "../../../Utils"; import { GooglePhotos } from '../../apis/google_docs/GooglePhotosClientUtils'; import { Docs, DocUtils } from "../../documents/Documents"; import { DocumentType } from '../../documents/DocumentTypes'; @@ -832,7 +831,7 @@ export class DocumentViewInternal extends DocComponent !SnappingManager.GetIsDragging() && Doc.BrushDoc(this.props.Document)} - onPointerLeave={e => hasDescendantTarget(e.nativeEvent.x, e.nativeEvent.y, this.ContentDiv) && Doc.UnBrushDoc(this.props.Document)} + onPointerLeave={e => !hasDescendantTarget(e.nativeEvent.x, e.nativeEvent.y, this.ContentDiv) && Doc.UnBrushDoc(this.props.Document)} style={{ borderRadius: this.borderRounding, pointerEvents: this.pointerEvents, -- cgit v1.2.3-70-g09d2