Skip to content

Nice to be able to query if an element is viewable #69

@Lee182

Description

@Lee182

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)
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions