aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index 97e7aefa2..b5dc5ab18 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -95,8 +95,6 @@ export class CollectionFreeFormView extends CollectionViewBase {
if (this._marquee) {
document.removeEventListener("keydown", this.marqueeCommand);
}
- document.removeEventListener("pointermove", this.onPointerMove);
- document.removeEventListener("pointerup", this.onPointerUp);
e.stopPropagation();
if (this._marquee) {
@@ -105,7 +103,6 @@ export class CollectionFreeFormView extends CollectionViewBase {
}
var selectedDocs = this.marqueeSelect();
selectedDocs.map(s => this.props.CollectionView.SelectedDocs.push(s.Id));
- this._marquee = false;
}
else if (!this._marquee && Math.abs(this._downX - e.clientX) < 3 && Math.abs(this._downY - e.clientY) < 3) {
//show preview text cursor on tap
@@ -115,11 +112,11 @@ export class CollectionFreeFormView extends CollectionViewBase {
this.props.select(false);
}
}
-
+ this.cleanupInteractions();
}
@action
- clearMarquee = () => {
+ cleanupInteractions = () => {
document.removeEventListener("pointermove", this.onPointerMove);
document.removeEventListener("pointerup", this.onPointerUp);
this._marquee = false;
@@ -136,7 +133,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
marqueeSelect() {
this.props.CollectionView.SelectedDocs.length = 0;
var curPage = this.props.Document.GetNumber(KeyStore.CurPage, 1);
- let p = this.getTransform().transformPoint(this._downX, this._downY);
+ let p = this.getTransform().transformPoint(this._downX < this._lastX ? this._downX : this._lastX, this._downY < this._lastY ? this._downY : this._lastY);
let v = this.getTransform().transformDirection(this._lastX - this._downX, this._lastY - this._downY);
let selRect = { left: p[0], top: p[1], right: p[0] + v[0], bottom: p[1] + v[1] }
@@ -187,23 +184,24 @@ export class CollectionFreeFormView extends CollectionViewBase {
marqueeCommand = (e: KeyboardEvent) => {
if (e.key == "Backspace") {
this.marqueeSelect().map(d => this.props.removeDocument(d));
- this.clearMarquee();
+ this.cleanupInteractions();
}
if (e.key == "c") {
- let p = this.getTransform().transformPoint(this._downX, this._downY);
+ let p = this.getTransform().transformPoint(this._downX < this._lastX ? this._downX : this._lastX, this._downY < this._lastY ? this._downY : this._lastY);
let v = this.getTransform().transformDirection(this._lastX - this._downX, this._lastY - this._downY);
+
let selected = this.marqueeSelect().map(m => m);
this.marqueeSelect().map(d => this.props.removeDocument(d));
//setTimeout(() => {
this.props.CollectionView.addDocument(Documents.FreeformDocument(selected.map(d => {
- d.SetNumber(KeyStore.X, d.GetNumber(KeyStore.X, 0) - p[0] - 400);
- d.SetNumber(KeyStore.Y, d.GetNumber(KeyStore.Y, 0) - p[1] - 400);
+ d.SetNumber(KeyStore.X, d.GetNumber(KeyStore.X, 0) - p[0] - v[0] / 2);
+ d.SetNumber(KeyStore.Y, d.GetNumber(KeyStore.Y, 0) - p[1] - v[1] / 2);
d.SetNumber(KeyStore.Page, this.props.Document.GetNumber(KeyStore.Page, 0));
d.SetText(KeyStore.Title, "" + d.GetNumber(KeyStore.Width, 0) + " " + d.GetNumber(KeyStore.Height, 0));
return d;
- }), { x: p[0], y: p[1], panx: 0, pany: 0, width: 800, height: 800, title: "a nested collection" }));
+ }), { x: p[0], y: p[1], panx: 0, pany: 0, width: v[0], height: v[1], title: "a nested collection" }));
// }, 100);
- this.clearMarquee();
+ this.cleanupInteractions();
}
}