Skip to content

Commit

Permalink
Merge pull request recogito#113 from oleksandr-danylchenko/recogito#112
Browse files Browse the repository at this point in the history
…-fix-transform-position-handling

recogito#112 Fixed mispositioned `canvas` when `container` has `transform` applied
  • Loading branch information
rsimon authored Jul 6, 2024
2 parents 83cdbd0 + da9199a commit fbe29fd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const createRenderer = (container: HTMLElement): RendererImplementation => {
const canvas = createCanvas();
const ctx = canvas.getContext('2d');

container.insertBefore(canvas, container.firstChild);
document.body.appendChild(canvas);

const redraw = (
highlights: Highlight[],
Expand Down Expand Up @@ -127,7 +127,7 @@ const createRenderer = (container: HTMLElement): RendererImplementation => {
}

const destroy = () => {
container.removeChild(canvas);
canvas.remove();

window.removeEventListener('resize', onResize);
}
Expand Down
9 changes: 4 additions & 5 deletions packages/text-annotator/src/presence/PresencePainter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Color, PresenceProvider, PresentUser } from '@annotorious/core';
import type { AnnotationRects } from '../state';
import type { HighlightStyle } from '../highlight/HighlightStyle';
import type { HighlightPainter } from '../highlight/HighlightPainter';
import type { PresencePainterOptions } from 'src/presence';
import type { HighlightStyle, HighlightPainter } from '../highlight';
import type { PresencePainterOptions } from '../presence';
import type { ViewportBounds } from '../highlight/viewport';

import './PresencePainter.css';
Expand Down Expand Up @@ -32,7 +31,7 @@ export const createPresencePainter = (

const ctx = canvas.getContext('2d');

container.appendChild(canvas);
document.body.appendChild(canvas);

const trackedAnnotations = new Map<string, PresentUser>();

Expand Down Expand Up @@ -117,4 +116,4 @@ export const createPresencePainter = (
reset
}

}
}
2 changes: 1 addition & 1 deletion packages/text-annotator/test/annotations.w3c.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@
}
]
}
]
]

0 comments on commit fbe29fd

Please sign in to comment.