Socket
Socket
Sign inDemoInstall

@zestia/ember-simple-infinite-scroller

Package Overview
Dependencies
397
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @zestia/ember-simple-infinite-scroller

Simple infinite scroller component for Ember apps


Version published
Weekly downloads
20K
decreased by-3.95%
Maintainers
3
Created
Weekly downloads
 

Changelog

Source

7.0.5

  • Upgrade dependencies

Readme

Source

@zestia/ember-simple-infinite-scroller

This Ember addon provides a simple component that fires an action whenever it is scrolled to the bottom. Allowing you to load more data. It is not coupled to Ember-Data like some other infinite scrolling implementations.

Installation

ember install @zestia/ember-simple-infinite-scroller

Demo

https://zestia.github.io/ember-simple-infinite-scroller/

Example

<InfiniteScroller @onLoadMore={{this.loadMore}} as |scroller|>
  {{#each things as |thing|}}
    ...
  {{/each}}
  {{if scroller.isLoading "Please wait..."}}
</InfiniteScroller>

Notes

  • Does not use jQuery ✔︎
  • Ember Data Friendly ✔︎
  • Supports use with FastBoot ✔︎

Configuration

ArgumentDescriptionDefault
onLoadMoreAction to perform when the bottom is scrolled into viewnull
selectorMonitors the scrolling of a specific child element, e.g. selector=".foo-bar"null
useDocumentMonitors the document scroll position rather than the element's scroll position.false
leewayPercentage distance away from the bottom"0%"
scrollDebounceMilliseconds delay used to check if the bottom has been reached100 ms

Yielded API

The component will yield a hash that provides:

PropertyDescription
isLoadingTrue when the promise for more data has not resolved yet
isScrollableTrue when scroll element is overflowing
errorThe caught error from the last attempt to load more
loadMoreAction for manually loading more

Element vs Document scroll

Either make your component scrollable:

.my-element {
  max-height: 300px;
  overflow-y: auto;
}

OR

Set @useDocument={{true}} if your component is not scrollable.

Performance

Please read: https://github.com/TryGhost/Ghost/issues/7934

You may need to add this to app/app.js

customEvents: {
  touchstart: null,
  touchmove: null,
  touchend: null,
  touchcancel: null
}

Other scenarios

If your scrollable element is displaying 10 things, but they don't cause the element to overflow, then the user won't ever be able to load more - because they won't be able to scroll and therefore the onLoadMore action will never fire.

To account for this, you can display a button for manually loading more...

<InfiniteScroller @onLoadMore={{this.loadMore}} as |scroller|>
  {{#each this.things as |thing|}}
    ...
  {{/each}}

  {{#if this.hasMoreThings}}
    {{#if scroller.isScrollable}}
      Loading more...
    {{else}}
      <button {{on "click" scroller.loadMore}}>Load more</button>
    {{/if}}
  {{/if}}
</InfiniteScroller>

Keywords

FAQs

Last updated on 05 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc