From d65eb3d3f516c6d761b273b93323ddd9dc5150a2 Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Tue, 17 Dec 2024 12:59:25 +0000 Subject: [PATCH] Synchronise comment blocks with document position Don't postpone and don't animate comment block position changes when scrolling or resizing the document. Signed-off-by: Chris Lord Change-Id: I95c1ae1eb732c6dc682018b85debb6133d85ce8c --- browser/src/canvas/sections/CommentListSection.ts | 13 ++++++++----- browser/src/canvas/sections/CommentSection.ts | 5 +++-- browser/src/dom/PosAnimation.js | 11 +++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/browser/src/canvas/sections/CommentListSection.ts b/browser/src/canvas/sections/CommentListSection.ts index 82b5181c0055..629c133fd08a 100644 --- a/browser/src/canvas/sections/CommentListSection.ts +++ b/browser/src/canvas/sections/CommentListSection.ts @@ -1250,7 +1250,10 @@ export class CommentSection extends app.definitions.canvasSectionObject { this.sectionProperties.selectedComment.hide(); } - this.update(); + var previousAnimationState = this.disableLayoutAnimation; + this.disableLayoutAnimation = true; + this.update(true); + this.disableLayoutAnimation = previousAnimationState; } private showHideComments (): void { @@ -2010,8 +2013,8 @@ export class CommentSection extends app.definitions.canvasSectionObject { this.disableLayoutAnimation = false; } - private layout (zoom: any = null): void { - if (zoom) + private layout (immediate: any = null): void { + if (immediate) this.doLayout(); else if (!this.sectionProperties.layoutTimer) { this.sectionProperties.layoutTimer = setTimeout(function() { @@ -2021,10 +2024,10 @@ export class CommentSection extends app.definitions.canvasSectionObject { } // else - avoid excessive re-layout } - private update (): void { + private update (immediate: boolean = false): void { if (this.sectionProperties.docLayer._docType === 'text') this.updateThreadInfoIndicator(); - this.layout(); + this.layout(immediate); } private updateThreadInfoIndicator(): void { diff --git a/browser/src/canvas/sections/CommentSection.ts b/browser/src/canvas/sections/CommentSection.ts index 46ca59d8e0f5..95fab1cb7dcc 100644 --- a/browser/src/canvas/sections/CommentSection.ts +++ b/browser/src/canvas/sections/CommentSection.ts @@ -337,9 +337,10 @@ export class Comment extends CanvasSectionObject { lastPosY = childPositions[i].posY + 24; } if (i < this.sectionProperties.childLines.length) { - for (let j = i; j < this.sectionProperties.childLines.length; j++) + for (let j = i; j < this.sectionProperties.childLines.length; j++) { this.sectionProperties.childLinesNode.removeChild(this.sectionProperties.childLines[i]); - this.sectionProperties.childLines.splice(i); + this.sectionProperties.childLines.splice(i); + } } } diff --git a/browser/src/dom/PosAnimation.js b/browser/src/dom/PosAnimation.js index cc258c30ae7a..b5ac8d1ec605 100644 --- a/browser/src/dom/PosAnimation.js +++ b/browser/src/dom/PosAnimation.js @@ -16,6 +16,17 @@ L.PosAnimation = L.Class.extend({ this.fire('start'); + // Skip some work if the duration is zero + if (duration <= 0) { + el.style[L.DomUtil.TRANSITION] = ''; + L.DomUtil.setPosition(el, newPos); + this._el._leaflet_pos = newPos; + this._inProgress = false; + this.fire('step').fire('end'); + this._el.dataset.transitioning = false; + return; + } + el.style[L.DomUtil.TRANSITION] = 'all ' + (isNaN(duration) ? 0.25 : 0) + 's cubic-bezier(0,0,' + (easeLinearity || 0.5) + ',1)';