Request: Expose some method for infinite scroll/pagination/scroll bottom
See original GitHub issueI’ve been trying to implement infinite scroll with ember-power-select, and none of the available public API’s allow a clean implementation. The closest I got was using the onopen
hook, but since the list is not rendered when onopen
fires the implementation looks like this (CoffeeScript… don’t judge…):
onopen: (options, e) ->
Ember.run.later =>
element = $(e.target).parents('.ember-basic-dropdown').find('ul')[0]
element?.addEventListener 'scroll', =>
if element.scrollHeight - element.scrollTop is element.clientHeight
@loadMore()
, 500
There’s two issues with this approach:
- The event target is sometimes the selected item
span
, sometimes adiv
(which isn’t a deal breaker) - The
500
ms delay is arbitrary, and subject to race conditions. Scheduling itafterRender
orrun.next
didn’t work (which is a deal breaker)
The way I see it, there’s three potential solutions:
- Moving
onopen
to fire after the list renders - Exposing an
afteropen
event - Exposing a
scrollbottom
event
Implementing a scrollbottom
isn’t too difficult. I got it mostly working by simply dropping this in didInsertElement
at addon/components/power-select/options.js
:
this.element.addEventListener('scroll', (e) => {
if(this.element.scrollHeight - this.element.scrollTop == this.element.clientHeight){
this.send('scrollBottom');
}
});
I might be able to throw some time at this if the maintainer(s?) would like to give some direction.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Infinite Scroll: Let's Get To The Bottom Of This
With infinite scrolling, social websites are doing their best to expose as much information as possible to the user.
Read more >Endless Scrolling with AdapterViews and RecyclerView
This is done by triggering a request for more data once the user crosses a threshold of remaining items before they've hit the...
Read more >Infinite Scrolling With React - Tutorial - YouTube
In this video I will be breaking down exact. ... Infinite scrolling is really just a fancy type of pagination that will paginate...
Read more >How to implement infinite scroll pagination in Flutter
The application starts by fetching the first ten posts. As the user scrolls down the page, it fetches more posts. Notice the position...
Read more >Infinite Scrolling with Android Paging Library and Flow API
data: the actual data. ... nextKey: the index of the next page or null if this is the last page. Error. which represents...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We worked around it by using the
afterOptionsComponent
hook. We’ve got a component that renders a “Load more…” button that loads in the next page of records. It’s working really well for us.In case anyone is interested - we’re managed to achieve pagination by extending
power-select/options
in a custom component:and then we’ve used a little trick with
optionsComponent
attribute ofpower-select
:This way we didn’t have to fork/copy-paste anything to make it work. Hope it helps somebody 😁