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

Rework virtual Scrolling #32

Closed
Webreaper opened this issue Nov 3, 2020 · 1 comment
Closed

Rework virtual Scrolling #32

Webreaper opened this issue Nov 3, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@Webreaper
Copy link
Owner

Webreaper commented Nov 3, 2020

  • Virtual folder list scrolling should be able to work regardless of the container size. Use the 'All' item to dynamically calculate the item height at runtime, and then use the container size to calculate scroll size and position.
  • Virtual image scroller should be smarter about pre-loading new results before the bottom of the page is hit (i.e., during scrolling)
@Webreaper Webreaper added the enhancement New feature or request label Nov 3, 2020
@Webreaper
Copy link
Owner Author

Webreaper commented Nov 19, 2020

Better approach:

  1. Find n-20 item in the list of images
  2. Wire it up to an observer as below
  3. The first time it scrolls into view, a) trigger LoadMore(), and b) stop observing it, and observe the next n-20 item.

https://stackoverflow.com/questions/487073/how-to-check-if-element-is-visible-after-scrolling

// this is the target which is observed
var target = document.querySelector('div')

// configure the intersection observer instance
var intersectionObserverOptions = {
  root: null,   // default is the viewport
  threshold: .5 // percentage of the taregt visible area which will trigger "onIntersection"
}
    
var observer = new IntersectionObserver(onIntersection, intersectionObserverOptions)

// called when target is fully visible
function onIntersection(entries, opts){
  entries.forEach(entry => {
    var visible = entry.intersectionRatio >= opts.thresholds[0]
    
    console.clear();
    console.log(entry.intersectionRatio.toFixed(2), visible)
    
    target.classList.toggle('visible', visible)
  })
}

// provide the observer with a target
observer.observe(target)

// To stop watching, do:
// observer.unobserve(entry.target)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant