Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: stop multiplying pin position by 100 in types other than html
Browse files Browse the repository at this point in the history
  • Loading branch information
Raspincel committed Jan 11, 2024
1 parent e7f9631 commit 4bee8e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/components/comments/html-pin-adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ export class HTMLPin implements PinAdapter {
this.addTemporaryPinToElement(elementId, temporaryPin);
}

const { width, height } = this.divWrappers.get(elementId).getBoundingClientRect();
const { x, y } = this.temporaryPinCoordinates;

temporaryPin.setAttribute('position', JSON.stringify({ x, y }));
Expand Down Expand Up @@ -726,8 +725,9 @@ export class HTMLPin implements PinAdapter {

const { width, height } = wrapper.getBoundingClientRect();

x /= width;
y = (y - 32) / height;
// save coordinates as percentages
x = (x * 100) / width;
y = ((y - 32) * 100) / height;
this.onPinFixedObserver.publish({
x,
y,
Expand Down
4 changes: 2 additions & 2 deletions src/web-components/comments/components/annotation-pin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ export class CommentsAnnotationPin extends WebComponentsBaseElement {

let style = '';
if (this.keepPositionRatio) {
style = `top: ${this.position.y * 100}%; left: ${this.position.x * 100}%;`;
style = `top: ${this.position.y}%; left: ${this.position.x}%;`;
} else {
style = `top: ${this.position.y * 100}px; left: ${this.position.x * 100}px;`;
style = `top: ${this.position.y}px; left: ${this.position.x}px;`;
}

if (this.type === PinMode.ADD) {
Expand Down

0 comments on commit 4bee8e7

Please sign in to comment.