3

I need something to calculate how much of the element is off screen—only in the top and bottom of it.

I'm using a snippet to see if the element is partially visible, so I just need to know how much of it is not visible.

I know it's something between the currenTop, element height and the size of what the user can see, but I think I'm missing something.

Adam Rackis
  • 82,527
  • 56
  • 270
  • 393
SilverSurfer8484
  • 93
  • 1
  • 1
  • 7
  • .position() method may come handy. It returns top and left position of an element. Bottom can be calculated adding the outerHeight of the element with position().top. – effone Mar 24 '14 at 18:47

1 Answers1

2

You should use the element.getBoundingClientRect() method and run calculations based on page position. The answer is detailed excellently in the question Retrieve the position (X,Y) of an HTML element.

Community
  • 1
  • 1
Steven Mann
  • 558
  • 3
  • 14