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

lowerElement is good but lowerVisibleElement is much better. #508

Closed
qnodesign opened this issue Aug 8, 2017 · 3 comments
Closed

lowerElement is good but lowerVisibleElement is much better. #508

qnodesign opened this issue Aug 8, 2017 · 3 comments

Comments

@qnodesign
Copy link

Hi, I would like to highlight that the lower element could be enhanced with the lower visible element option so if I have eg. a scrollable list with hundreds of elements, but the UL only 300px the resize will measure the last LI instead of the UL.

In my case the taggedElement would be a big overhead as I show and hide content and would be much complicated instead of checking the last visible element lowest position.

@davidjbradshaw
Copy link
Owner

davidjbradshaw commented Aug 8, 2017 via email

@Rycochet
Copy link

For the pseudo-code:

var walker = document.createTreeWalker(body, ...),
      bottom = body.height + padding;

while(node) {
   var node = walker.next();

   if (node.style.display != "none") {
      bottom = Math.max(bottom, node.getBoundingClientRect().bottom);
      if (node != body &&  node.style.overflow == "hidden") {
         node = walker.nextSibling();
      } else {
         node = walker.next();
      }
   }
}

It probably wants splitting up into a filter for the overflow and normal .next for the loop to take a little overhead off it. Also (obviously I hope), window.getComputedStyle (cache it, and case insensitive).

Not got enough spare time to do proper code and a PR myself here, but hopefully it's helpful (and there'll be more feedback) - and if nobody else has done one when I do get time then I'll happily PR :-)

Logic for ignoring the overflow on the body is simply because a lot of pages hide the overflow on it to prevent scrolling, but actually want to grow to fit so there's no need for scrolling.

@davidjbradshaw
Copy link
Owner

Added :not(option):not(optgroup) to querySelectorAll('body *') in v5.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants