From b9ba531c64fe7926a6794ab57e4989e1ea6c6992 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Fri, 10 Jul 2020 11:23:44 -0400 Subject: fixes for x/y panning on drag --- .../collectionFreeForm/CollectionFreeFormView.tsx | 66 ++++++---------------- 1 file changed, 16 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index f2a39b240..3fdf6683e 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -84,6 +84,8 @@ export class CollectionFreeFormView extends CollectionSubView = new Map(); @@ -579,7 +581,7 @@ export class CollectionFreeFormView extends CollectionSubView { - this._lastClientY = undefined; + this._lastClientY = this._lastClientX = undefined; if (InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE)) return; document.removeEventListener("pointermove", this.onPointerMove); @@ -1172,76 +1174,40 @@ export class CollectionFreeFormView extends CollectionSubView - _lastClientY: number | undefined = 0; @action handleDragging = (e: CustomEvent, de: DragEvent) => { if ((e as any).handlePan) return; (e as any).handlePan = true; - const top = this.panX(); - const left = this.panY(); this._lastClientY = e.detail.clientY; - - console.log("draggg"); - - const size = this.getTransform().transformDirection(this.props.PanelWidth(), this.props.PanelHeight()); - const scale = this.getLocalTransform().inverse().Scale; + this._lastClientX = e.detail.clientX; if (this._marqueeRef?.current) { - - console.log("hellp"); - const dragX = e.detail.clientX; const dragY = e.detail.clientY; const bounds = this._marqueeRef.current?.getBoundingClientRect(); - if (dragX - bounds.left < 25) { - console.log("PAN left "); - - if (this.canPanX) { - this.Document._panX = left - 5; - setTimeout(action(() => { - this.canPanX = true; - this.panX(); - }), 250); - this.canPanX = false; - } - } else if (bounds.right - dragX < 25) { - console.log("PAN right "); - - if (this.canPanX) { - this.Document._panX = left + 5; - setTimeout(action(() => { - this.panX(); - this.canPanX = true; - }), 250); - this.canPanX = false; - } - - } - - if (dragY - bounds.top < 25) { - console.log("PAN top "); - this.continueYPan(-2); - } else if (bounds.bottom - dragY < 25) { - console.log("PAN bottom "); - this.continueYPan(2); - } + let deltaX = dragX - bounds.left < 25 ? -2 : bounds.right - dragX < 25 ? 2 : 0; + let deltaY = dragY - bounds.top < 25 ? -2 : bounds.bottom - dragY < 25 ? 2 : 0; + (deltaX !== 0 || deltaY !== 0) && this.continuePan(deltaX, deltaY); } e.stopPropagation(); } - continueYPan = (delta: number) => { + continuePan = (deltaX: number, deltaY: number) => { setTimeout(() => { const dragY = this._lastClientY; - if (dragY !== undefined && this._marqueeRef.current) { + const dragX = this._lastClientX; + if (dragY !== undefined && dragX !== undefined && this._marqueeRef.current) { const bounds = this._marqueeRef.current.getBoundingClientRect()!; - this.Document._panY = NumCast(this.Document._panY) + delta; - (dragY - bounds.top < 25 || bounds.bottom - dragY < 25) && this.continueYPan(delta); - } else this._lastClientY !== undefined && this.continueYPan(delta); + this.Document._panY = NumCast(this.Document._panY) + deltaY; + this.Document._panX = NumCast(this.Document._panX) + deltaX; + if (dragY - bounds.top < 25 || bounds.bottom - dragY < 25 || dragX - bounds.left < 25 || bounds.right - dragX < 25) { + this.continuePan(deltaX, deltaY); + } + } else this._lastClientY !== undefined && this._lastClientX !== undefined && this.continuePan(deltaX, deltaY); }, 50); } - promoteCollection = undoBatch(action(() => { const childDocs = this.childDocs.slice(); childDocs.forEach(doc => { -- cgit v1.2.3-70-g09d2 From d064024d9ab2cd8e836df5ba75e064d77617445b Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Fri, 10 Jul 2020 11:25:08 -0400 Subject: from last --- .../views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 3fdf6683e..2191021d2 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -1194,7 +1194,7 @@ export class CollectionFreeFormView extends CollectionSubView { - setTimeout(() => { + setTimeout(action(() => { const dragY = this._lastClientY; const dragX = this._lastClientX; if (dragY !== undefined && dragX !== undefined && this._marqueeRef.current) { @@ -1205,7 +1205,7 @@ export class CollectionFreeFormView extends CollectionSubView { -- cgit v1.2.3-70-g09d2