aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 0b7bf92cc..f60af6355 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -605,9 +605,11 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P
this.removeMoveListeners();
this.removeEndListeners();
if (CurrentUserUtils.SelectedTool !== InkTool.None) {
- this._deleteList.forEach(ink => {
- ink.props.removeDocument?.(ink.props.Document);
- });
+ if (this._deleteList.length > 0) {
+ this._deleteList.forEach(ink => {
+ ink.props.removeDocument?.(ink.props.Document);
+ });
+ }
this._prevPoint = this._currPoint = { X: -1, Y: -1 };
this._deleteList = [];
}
@@ -641,12 +643,15 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P
if (InteractionUtils.IsType(e, InteractionUtils.PENTYPE)) return;
if (CurrentUserUtils.SelectedTool !== InkTool.None) {
this._currPoint = { X: e.clientX, Y: e.clientY };
- const intersectStroke = this.getInkIntersection();
- if (intersectStroke) {
- if (!this._deleteList.includes(intersectStroke)) {
- this._deleteList.push(intersectStroke);
- // lower intersectStroke opacity to give user a visual indicator
- }
+ const intersections: DocumentView[] = this.getInkIntersection();
+ if (intersections.length > 0) {
+ intersections.forEach(ink =>{
+ if (!this._deleteList.includes(ink)) {
+ this._deleteList.push(ink);
+ // Lowering ink opacity to give the user a visual indicator of deletion.
+ ink.Document.opacity = 0.5;
+ }
+ });
}
}
if (InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE)) {
@@ -668,24 +673,27 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P
* Determines if the Eraser tool has intersected with an ink stroke in the current freeform collection.
* @returns The DocumentView of the intersected stroke.
*/
- getInkIntersection = (): DocumentView | null => {
- console.log("in intersection");
- const currentCollection = this.props.CollectionFreeFormDocumentView?.().props.CollectionFreeFormView;
- currentCollection?.childDocs
+ getInkIntersection = (): DocumentView[] => {
+ const inks: DocumentView[] = [];
+ this.childDocs
.filter(doc => doc.type === DocumentType.INK)
.forEach(doc => {
- console.log("in for each");
const inkView = DocumentManager.Instance.getDocumentView(doc, this.props.CollectionView);
const ctrlPoints = Cast(inkView?.dataDoc[this.props.fieldKey], InkField)?.inkData ?? [];
for (var i = 0; i < ctrlPoints.length - 3; i += 4) {
const array = [ctrlPoints[i], ctrlPoints[i + 1], ctrlPoints[i + 2], ctrlPoints[i + 3]];
- const intersects = new Bezier(array.map(p => ({ x: p.X, y: p.Y }))).intersects(
- { p1: { x: this._prevPoint.X, y: this._prevPoint.Y },
- p2: { x: this._currPoint.X, y: this._currPoint.Y } });
- if (intersects) return inkView;
+ // Converting from screen space to ink space for the intersection.
+ const prevPointInkSpace = inkView?.ComponentView?.ptFromScreen?.(this._prevPoint);
+ const currPointInkSpace = inkView?.ComponentView?.ptFromScreen?.(this._currPoint);
+ if (prevPointInkSpace && currPointInkSpace) {
+ const intersects = new Bezier(array.map(p => ({ x: p.X, y: p.Y }))).intersects(
+ { p1: { x: prevPointInkSpace.X, y: prevPointInkSpace.Y },
+ p2: { x: currPointInkSpace.X, y: currPointInkSpace.Y } });
+ if (inkView && intersects.length > 0) inks.push(inkView);
+ }
}
});
- return null;
+ return inks;
}
handle1PointerMove = (e: TouchEvent, me: InteractionUtils.MultiTouchEvent<TouchEvent>) => {