Skip to content

Commit d65eb3d

Browse files
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 1af2a5c commit d65eb3d

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

browser/src/canvas/sections/CommentListSection.ts

Lines changed: 8 additions & 5 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 11 additions & 0 deletions
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)