Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Lee182 opened this issue Aug 7, 2019 · 0 comments
Open

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

Lee182 opened this issue Aug 7, 2019 · 0 comments

Comments

@Lee182
Copy link

Lee182 commented Aug 7, 2019

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)
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant