zenscroll icon indicating copy to clipboard operation
zenscroll copied to clipboard

Nice to be able to query if an element is viewable

Open Lee182 opened this issue 5 years ago • 0 comments

Here is the code I would like to simplify

      const scrollerHeight = container.clientHeight
      const scrollerY = scroller.getY()
      const targetHegiht = target.clientHeight
      const targetY = scroller.getTopOf(target)
      if (targetY + targetHegiht > scrollerY + scrollerHeight || targetY < scrollerY) {
        // the target is not fully within the vertical scroll bar
        scroller.center(target, 1000)
      } else {
        scroller.intoView(target, 1000)
      }
      if (!scroller.isFullyInView(target)) {
        scroller.center(target, 1000)
      } else {
        scroller.intoView(target, 1000)
      }

Lee182 avatar Aug 07 '19 01:08 Lee182