G
G
Guzh2017-09-26 18:42:14
css
Guzh, 2017-09-26 18:42:14

How can you track (using React) that part or all of a component is rendered outside of the user's visible area?

There is a component which is located at the right edge. When you click on it, a list expands, part of which is "hidden" outside the visible area. How can this be tracked and prevented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexKeller, 2017-09-27
@Guzh

On componentDidMount get its position via Element.getBoundingClientRect and look at the right property. If it is greater than window.innerWidth, then move the component to the left so that it all fits into the visible area

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question