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

Failing to load more if items dont fill the screen #224

Open
snewcomer opened this issue Jan 31, 2020 · 1 comment
Open

Failing to load more if items dont fill the screen #224

snewcomer opened this issue Jan 31, 2020 · 1 comment

Comments

@snewcomer
Copy link
Collaborator

No description provided.

@Techn1x
Copy link

Techn1x commented Sep 29, 2021

A solution if anyone stumbles onto this like I did - if you hide the loader/viewport element while the loader task is running, the viewport element will be re-added into the template when the task finishes (is idle), if this is still in the viewport, it'll fire the on enter hook again - and it'll repeat until items fill the screen

@tracked items = []

@task
loadItems() { ... }

@action
loadMoreItems() { this.loadItems.perform() }
{{#each this.items as |item|}}
  {{item.name}}
{{/each}}
{{#if this.loadItems.isIdle}}
  <div {{in-viewport onEnter=this.loadMoreItems}} />
{{else if this.loadItems.isRunning}}
  loading spinner
{{/if}}

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

2 participants