diegomura / diegomura/react-pdf

How to check if a component touches another?

Open
#1,519 4 comments 0 reactions 0 assignees View on GitHub
new feature
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

Is it possible to determine whether two View components overlap or collide with each other. I'm trying to check whether if a component touches the page footer so that I could break the component into two parts and display them on two different pages?

I've tried to using getBoundingClientRect() to check for collision but the function returns DOMRect {x: 0, y: 0, width: 0, height: 0, top: 0, …} for components contained inside PDFViewer.

![image](https://user-images.githubusercontent.com/87088870/134441799-94cfefbb-7f4f-4be8-83ce-41c88e1d9138.png)

Browser: Chrome 93
@react-pdf/renderer version: 2.0.19
React version: 17.0.2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.