wellyshen / react-cool-inview

😎 🖥️ React hook to monitor an element enters or leaves the viewport (or another element).

Home Page:https://react-cool-inview.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rootMargin must have pixel or percentage unit, but the “Trigger Animations” example uses a rootMargin of "-100px 0" which throws an error.

brandondurham opened this issue · comments

Bug Report

Describe the Bug

In the README file the Trigger Animations example uses a value of "-100px 0" for rootMargin, but rootMargin requires absolute pixel or percent units, otherwise it throws the following error:

Failed to construct 'IntersectionObserver': rootMargin must be specified in pixels or percent.

How to Reproduce

Just follow the example set in the Trigger Animations section of the README.

CodeSandbox Link

https://codesandbox.io/s/react-cool-inview-example-forked-bcf57

Expected Behavior

0 shouldn’t require a unit.

Screenshots

Add screenshots to help explain your problem.
image

Your Environment

  • Device: MacBook
  • OS: macOS BigSur 11.1
  • Browser: Chrome
  • Version: 89.0.4389.90 (Official Build) (x86_64)

@brandondurham Sorry for the late reply, I have updated the READ.md.

Thank you!