client/notes: make content appear at centroids
Previously it used the centroid of polygon's bounding box, not the polygon's centroid.
This commit is contained in:
parent
b7149ba7d6
commit
3235d70b1b
|
@ -648,19 +648,19 @@ class PostNotesOverlayControl extends events.EventTarget {
|
||||||
this._textNode.querySelector('.wrapper').innerHTML =
|
this._textNode.querySelector('.wrapper').innerHTML =
|
||||||
misc.formatMarkdown(note.text);
|
misc.formatMarkdown(note.text);
|
||||||
this._textNode.style.display = 'block';
|
this._textNode.style.display = 'block';
|
||||||
const polygonRect = note.polygonNode.getBBox();
|
|
||||||
const bodyRect = document.body.getBoundingClientRect();
|
const bodyRect = document.body.getBoundingClientRect();
|
||||||
const noteRect = this._textNode.getBoundingClientRect();
|
const noteRect = this._textNode.getBoundingClientRect();
|
||||||
const svgRect = this.boundingBox;
|
const svgRect = this.boundingBox;
|
||||||
|
const centroid = _getNoteCentroid(note);
|
||||||
const x = (
|
const x = (
|
||||||
-bodyRect.left +
|
-bodyRect.left +
|
||||||
svgRect.left +
|
svgRect.left +
|
||||||
svgRect.width * (polygonRect.x + polygonRect.width / 2) -
|
svgRect.width * centroid.x -
|
||||||
noteRect.width / 2);
|
noteRect.width / 2);
|
||||||
const y = (
|
const y = (
|
||||||
-bodyRect.top +
|
-bodyRect.top +
|
||||||
svgRect.top +
|
svgRect.top +
|
||||||
svgRect.height * (polygonRect.y + polygonRect.height / 2) -
|
svgRect.height * centroid.y -
|
||||||
noteRect.height / 2);
|
noteRect.height / 2);
|
||||||
this._textNode.style.left = x + 'px';
|
this._textNode.style.left = x + 'px';
|
||||||
this._textNode.style.top = y + 'px';
|
this._textNode.style.top = y + 'px';
|
||||||
|
|
Loading…
Reference in New Issue