summaryrefslogtreecommitdiffstats
path: root/browser
diff options
context:
space:
mode:
authorMert Tumer <mert.tumer@collabora.com>2022-07-28 13:34:19 +0300
committerMert Tümer <merttumer@outlook.com>2022-08-04 16:07:05 +0300
commit6ca86d93afea22e5548572bf7a36c4a50d28d3e5 (patch)
treedd4b29c1dffa8144fc917ce9c755b220388f05a1 /browser
parentadd .xlsm mimetype to android (diff)
downloadonline-6ca86d93afea22e5548572bf7a36c4a50d28d3e5.tar.gz
online-6ca86d93afea22e5548572bf7a36c4a50d28d3e5.zip
fix selecting redline comment jumps to scroll to beginning
redline comments dont have position properties set and some calculation needed in order to have it and scrolling to comment relies on position property. We have now instead getter for it and if it is a redline comment it is calculated otherwise the default one is returned because it is already set. Signed-off-by: Mert Tumer <mert.tumer@collabora.com> Change-Id: I6a3cefdd1c881783832de3de8fc1df7c849aad09
Diffstat (limited to 'browser')
-rw-r--r--browser/src/layer/tile/CommentListSection.ts11
-rw-r--r--browser/src/layer/tile/CommentSection.ts35
2 files changed, 35 insertions, 11 deletions
diff --git a/browser/src/layer/tile/CommentListSection.ts b/browser/src/layer/tile/CommentListSection.ts
index 4c57ecde67..ee9e33fd24 100644
--- a/browser/src/layer/tile/CommentListSection.ts
+++ b/browser/src/layer/tile/CommentListSection.ts
@@ -616,9 +616,9 @@ class CommentSection {
if (this.sectionProperties.docLayer._docType === 'text') {
// check it is visible in the screen and not a new comment
const id = this.sectionProperties.selectedComment.sectionProperties.data.id;
- if (id.indexOf('new') < 0 && !this.isInViewPort(this.sectionProperties.selectedComment)) {
- const scrollToPos = this.sectionProperties.selectedComment.position[1];
- this.map.scrollTop(scrollToPos < 0 ? 0 : scrollToPos);
+ const position = this.sectionProperties.selectedComment.getPosition();
+ if (id.indexOf('new') < 0 && !this.isInViewPort(this.sectionProperties.selectedComment) && position[1] !== 0) {
+ this.map.scrollTop(position[1] < 0 ? 0 : position[1]);
}
}
}
@@ -635,8 +635,9 @@ class CommentSection {
const scrollSection = app.sectionContainer.getSectionWithName(L.CSections.Scroll.name);
const screenTop = scrollSection.containerObject.getDocumentTopLeft()[1];
const screenBottom = screenTop + (window.innerHeight || document.documentElement.clientHeight);
- const annotationTop = annotation.position[1];
- const annotationBottom = annotation.position[1] + rect.bottom - rect.top;
+ const position = annotation.getPosition();
+ const annotationTop = position[1];
+ const annotationBottom = position[1] + rect.bottom - rect.top;
return (
screenTop <= annotationTop &&
diff --git a/browser/src/layer/tile/CommentSection.ts b/browser/src/layer/tile/CommentSection.ts
index b61212fcf1..6f69603b07 100644
--- a/browser/src/layer/tile/CommentSection.ts
+++ b/browser/src/layer/tile/CommentSection.ts
@@ -482,20 +482,43 @@ class Comment {
} else if (this.sectionProperties.data.trackchange && this.sectionProperties.data.anchorPos) {
// For redline comments there are no 'rectangles' or 'rectangleOriginal' properties in sectionProperties.data
// So use the comment rectangle stored in anchorPos (in display? twips).
+ pos = this.getPosition();
+ size = this.getSize();
+
+ intersectsVisibleArea = Comment.doesRectIntersectView(pos, size, viewContext);
+ }
+
+ return intersectsVisibleArea;
+ }
+
+ public getPosition () {
+ // For redline comments there are no 'rectangles' or 'rectangleOriginal' properties in sectionProperties.data
+ // So use the comment rectangle stored in anchorPos (in display? twips).
+ if (this.sectionProperties.data.trackchange && this.sectionProperties.data.anchorPos) {
+ var ratio: number = (app.tile.size.pixels[0] / app.tile.size.twips[0]);
var anchorPos = this.sectionProperties.data.anchorPos;
- pos = [
+ return [
Math.round(anchorPos[0] * ratio),
Math.round(anchorPos[1] * ratio)
];
- size = [
+ } else {
+ return this.position;
+ }
+ }
+
+ public getSize() {
+ // For redline comments there are no 'rectangles' or 'rectangleOriginal' properties in sectionProperties.data
+ // So use the comment rectangle stored in anchorPos (in display? twips).
+ if (this.sectionProperties.data.trackchange && this.sectionProperties.data.anchorPos) {
+ var ratio: number = (app.tile.size.pixels[0] / app.tile.size.twips[0]);
+ var anchorPos = this.sectionProperties.data.anchorPos;
+ return [
Math.round(anchorPos[2] * ratio),
Math.round(anchorPos[3] * ratio)
];
-
- intersectsVisibleArea = Comment.doesRectIntersectView(pos, size, viewContext);
+ } else {
+ return this.size;
}
-
- return intersectsVisibleArea;
}
private updatePosition () {