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

Commit

Permalink
Merge pull request #502 from SuperViz/fix/update-comments-wrapper-pos…
Browse files Browse the repository at this point in the history
…ition

fix: update comments position and fix creating first comment
  • Loading branch information
carlossantos74 authored Jan 15, 2024
2 parents d81a8df + efbfec1 commit 6090bcc
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/components/comments/canvas-pin-adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class CanvasPin implements PinAdapter {
private animate = (): void => {
if (this.isActive || this.isPinsVisible) {
this.renderAnnotationsPins();
this.renderDivWrapper();
this.divWrapper = this.renderDivWrapper();
}

if (this.temporaryPinCoordinates) {
Expand All @@ -258,24 +258,30 @@ export class CanvasPin implements PinAdapter {
* */
private renderDivWrapper(): HTMLElement {
const canvasRect = this.canvas.getBoundingClientRect();
const divWrapper = document.createElement('div');
divWrapper.id = 'superviz-canvas-wrapper';
let wrapper = this.divWrapper;

if (!wrapper) {
wrapper = document.createElement('div')
wrapper.id = 'superviz-canvas-wrapper';
if (['', 'static'].includes(this.canvas.parentElement.style.position)) {
this.canvas.parentElement.style.position = 'relative';
};
}

this.canvas.parentElement.style.position = 'relative';

divWrapper.style.position = 'fixed';
divWrapper.style.top = `${canvasRect.top}px`;
divWrapper.style.left = `${canvasRect.left}px`;
divWrapper.style.width = `${canvasRect.width}px`;
divWrapper.style.height = `${canvasRect.height}px`;
divWrapper.style.pointerEvents = 'none';
divWrapper.style.overflow = 'hidden';
wrapper.style.position = 'absolute';
wrapper.style.top = `${this.canvas.offsetTop}px`;
wrapper.style.left = `${this.canvas.offsetLeft}px`;
wrapper.style.width = `${canvasRect.width}px`;
wrapper.style.height = `${canvasRect.height}px`;
wrapper.style.pointerEvents = 'none';
wrapper.style.overflow = 'hidden';

if (!document.getElementById('superviz-canvas-wrapper')) {
this.canvas.parentElement.appendChild(divWrapper);
this.canvas.parentElement.appendChild(wrapper);
}

return divWrapper;
return wrapper;
}

/**
Expand All @@ -284,7 +290,7 @@ export class CanvasPin implements PinAdapter {
* @returns {void}
*/
private renderAnnotationsPins(): void {
if (!this.annotations.length || this.canvas.style.display === 'none') {
if ((!this.annotations.length || this.canvas.style.display === 'none') && !this.pins.get('temporary-pin')) {
this.removeAnnotationsPins();
return;
}
Expand Down

0 comments on commit 6090bcc

Please sign in to comment.