Skip to content

Is it possible to measure another element? #484

Closed

Description

@Zloka

Hi, thanks for a very convenient hook!

I was wondering if it is possible to observe some other element? I.e. I have a component, but I would not like to assign the ref to the component I am returning, rather I want this component to observe and take action based on whether or not another component is intersecting the viewport. I figured I would find it e.g. using document.getElementById.

Effectively, I am trying to detect whether or not a toolbar is active, as it has a fixed position at the top of the screen and is overlapping some of my content. Sadly, it's a piece of functionality integrated from a third party, so I don't have much control over it in my React tree/state management.

Activity

  1. thebuilder commented on Jun 23, 2021

    @thebuilder
    Owner

    You can call the ref() with an element inside an useEffect. This would allow you set it to the element you get from getElementById.

  2. thebuilder commented on Jun 23, 2021

    @thebuilder
    Owner

    See #480 for a few different ideas

  3. Repository owner locked and limited conversation to collaborators on Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions