From 861dc41cfd8f9727f9094492904c17e016ecc501 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 14 Sep 2023 14:03:07 -0400 Subject: [PATCH] Allow starting from end when annotating with touch --- src/dom/common/dom-view.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dom/common/dom-view.tsx b/src/dom/common/dom-view.tsx index e0d232b5..f6014427 100644 --- a/src/dom/common/dom-view.tsx +++ b/src/dom/common/dom-view.tsx @@ -916,6 +916,10 @@ abstract class DOMView { let range = this._iframeDocument.createRange(); range.setStart(this._touchAnnotationStartPosition.offsetNode, this._touchAnnotationStartPosition.offset); range.setEnd(endPos.offsetNode, endPos.offset); + if (range.collapsed) { + range.setStart(endPos.offsetNode, endPos.offset); + range.setEnd(this._touchAnnotationStartPosition.offsetNode, this._touchAnnotationStartPosition.offset); + } let annotation = this._getAnnotationFromRange(range, this._tool.type, this._tool.color); if (annotation) { this._previewAnnotation = annotation;