Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get position of element in react

showBanner(e) {
  const rect = this.btnDownload.current.getBoundingClientRect()

  const isInView = rect.top < window.innerHeight
  const isAtTop = rect.top <= 0

  console.log('Is in view:', isInView)
  console.log('Is at top:', isAtTop)
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #position #element #react
ADD COMMENT
Topic
Name
4+9 =