Skip to content

Commit

Permalink
fix: get correct position info of canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
justusmattern27 committed Oct 3, 2024
1 parent 8e1f558 commit 3d321de
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/player-react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,17 @@ export function Player({
const handlePlayerResize = useCallback(
(entries: ResizeObserverEntry[]) => {
const [firstEntry] = entries;
if (!firstEntry || !wrapperRef.current || !lastRect.current) {
if (!firstEntry || !wrapperRef.current) {
return;
}

const newRect = firstEntry.contentRect;
const newRect = wrapperRef.current.getBoundingClientRect();
if (
!lastRect.current ||
newRect.width !== lastRect.current.width ||
newRect.height !== lastRect.current.height
newRect.height !== lastRect.current.height ||
newRect.x !== lastRect.current.x ||
newRect.y !== lastRect.current.y
) {
lastRect.current = newRect;
onPlayerResize(newRect);
Expand Down

0 comments on commit 3d321de

Please sign in to comment.