Skip to content

Commit 91a604e

Browse files
author
Chris Lord
committed
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 <[email protected]> Change-Id: I95c1ae1eb732c6dc682018b85debb6133d85ce8c
1 parent 71ba183 commit 91a604e

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

browser/src/canvas/sections/CommentListSection.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,10 @@ export class CommentSection extends app.definitions.canvasSectionObject {
12501250
this.sectionProperties.selectedComment.hide();
12511251
}
12521252

1253-
this.update();
1253+
var previousAnimationState = this.disableLayoutAnimation;
1254+
this.disableLayoutAnimation = true;
1255+
this.update(true);
1256+
this.disableLayoutAnimation = previousAnimationState;
12541257
}
12551258

12561259
private showHideComments (): void {
@@ -2010,8 +2013,8 @@ export class CommentSection extends app.definitions.canvasSectionObject {
20102013
this.disableLayoutAnimation = false;
20112014
}
20122015

2013-
private layout (zoom: any = null): void {
2014-
if (zoom)
2016+
private layout (immediate: any = null): void {
2017+
if (immediate)
20152018
this.doLayout();
20162019
else if (!this.sectionProperties.layoutTimer) {
20172020
this.sectionProperties.layoutTimer = setTimeout(function() {
@@ -2021,10 +2024,10 @@ export class CommentSection extends app.definitions.canvasSectionObject {
20212024
} // else - avoid excessive re-layout
20222025
}
20232026

2024-
private update (): void {
2027+
private update (immediate: boolean = false): void {
20252028
if (this.sectionProperties.docLayer._docType === 'text')
20262029
this.updateThreadInfoIndicator();
2027-
this.layout();
2030+
this.layout(immediate);
20282031
}
20292032

20302033
private updateThreadInfoIndicator(): void {

browser/src/canvas/sections/CommentSection.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,10 @@ export class Comment extends CanvasSectionObject {
337337
lastPosY = childPositions[i].posY + 24;
338338
}
339339
if (i < this.sectionProperties.childLines.length) {
340-
for (let j = i; j < this.sectionProperties.childLines.length; j++)
340+
for (let j = i; j < this.sectionProperties.childLines.length; j++) {
341341
this.sectionProperties.childLinesNode.removeChild(this.sectionProperties.childLines[i]);
342-
this.sectionProperties.childLines.splice(i);
342+
this.sectionProperties.childLines.splice(i);
343+
}
343344
}
344345

345346
}

browser/src/dom/PosAnimation.js

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ L.PosAnimation = L.Class.extend({
1616

1717
this.fire('start');
1818

19+
// Skip some work if the duration is zero
20+
if (duration <= 0) {
21+
el.style[L.DomUtil.TRANSITION] = '';
22+
L.DomUtil.setPosition(el, newPos);
23+
this._el._leaflet_pos = newPos;
24+
this._inProgress = false;
25+
this.fire('step').fire('end');
26+
this._el.dataset.transitioning = false;
27+
return;
28+
}
29+
1930
el.style[L.DomUtil.TRANSITION] = 'all ' + (isNaN(duration) ? 0.25 : 0) +
2031
's cubic-bezier(0,0,' + (easeLinearity || 0.5) + ',1)';
2132

0 commit comments

Comments
 (0)