Giter Site home page Giter Site logo

jonasgeiler / svelte-infinite-loading Goto Github PK

View Code? Open in Web Editor NEW
255.0 9.0 11.0 87 KB

An infinite scroll component for Svelte, to help you implement an infinite scroll list more easily.

License: MIT License

JavaScript 20.67% Svelte 79.33%
svelte svelte-components infinite loading scroll component plugin spinner

svelte-infinite-loading's Introduction

InfiniteLogo

svelte-infinite-loading

An infinite scroll component for Svelte apps

NPM VERSION NPM DOWNLOADS DEPENDENCIES

AboutFeaturesInstallationDocumentationExamplesLicense

About

An infinite scroll component for Svelte, to help you implement an infinite scroll list more easily.
This is heavily inspired by vue-infinite-loading and uses most of its code and functionality!

Features

  • Mobile friendly
  • Built-in spinners
  • 2-directional support
  • Load result message display

Installation

If you're using this component in a Sapper application, make sure to install the package to devDependencies!
More Details

With npm:

$ npm install svelte-infinite-loading

With yarn:

$ yarn add svelte-infinite-loading

With pnpm (recommended):

$ npm i -g pnpm
$ pnpm install svelte-infinite-loading

From CDN (via unpkg):

<!-- UMD -->
<script src="https://unpkg.com/svelte-infinite-loading@^1/dist/svelte-infinite-loading.js"></script>

<!-- ES Module -->
<script src="https://unpkg.com/svelte-infinite-loading@^1/dist/svelte-infinite-loading.mjs"></script>

Examples / Demo

For more information on how to use this library, check the documentation!

Documentation

You can find the documentation in the repository wiki

License

MIT License

svelte-infinite-loading's People

Contributors

jonasgeiler avatar kefahi avatar

Stargazers

oxomoto avatar Alex Bäuerle avatar anthonyivol avatar Ali nazari  avatar Markus Hamacher avatar Teroy Goph avatar tomixy avatar Mark Molnar avatar Emel avatar Matteo Serafini avatar Bram avatar Josh  avatar @randydaniel avatar  avatar MS avatar Nicolas Montavon avatar Adam McKee avatar  avatar Luca Patera avatar  avatar Johannes Klauss avatar mathis avatar William Faircloth avatar A avatar Sandalots avatar Tristan F. avatar Joey avatar  avatar egecvs avatar takez0_o avatar  avatar  avatar Min Byeong-Guk avatar Ayush Sehrawat  avatar Alex White avatar Remco Janssen avatar Christian Hosh avatar zxlan avatar Peter John Arao avatar  avatar Mitchell Goldberg avatar Jian Yuan Lee avatar George Universe avatar 88da33f9 avatar CTRL avatar  avatar Muslem Rahimi avatar Domenico Testa avatar smari avatar Al Murray avatar Charlie Yaris avatar Thea Vanherst avatar MikeThuchchai avatar  avatar Andreas Faust avatar Romek avatar Daniel avatar Miu avatar Gabriel Tavares avatar Filip Lauc avatar Bruno De Simone avatar Aleksandr Sadovoj avatar Ethan Hathaway avatar Jonas avatar David Hodgson avatar Ward avatar VTF avatar Ilya Borodinov avatar  avatar Brave avatar  avatar HaxRob avatar nam avatar  avatar Kıraç Armağan Önal avatar Cesar Napoleon Mejia Leiva avatar red avatar Jerric Lyns John avatar Amirul Islam avatar Pawan Paudel avatar Shunya Abe avatar Rohan Rajpal avatar Shayon avatar Adam Slatinský avatar  avatar  avatar Sanjay Maurya avatar  avatar LNAhri avatar Matthew avatar Shlomi Atar avatar  avatar  avatar  avatar  avatar Ivar Løvlie avatar Francisco Boni avatar Kolja avatar netop://ウエハ avatar  avatar

Watchers

Martin avatar Mike Sozanski avatar James Cloos avatar  avatar George Universe avatar  avatar  avatar DemonoiD avatar  avatar

svelte-infinite-loading's Issues

[Help] How to use "identifier" ?

Grüß Gott,

i tried to reset the list on click of as button.
So i can change the filter on the backend providing the list and restart with a fresh list. ;)

i assumed something like this should do it:

<script>
  let infiniteId = 1;

  function handleButton() {
    console.debug('Klick', infiniteId);
    infiniteId += 1;
  }
</script>

bla bla...

        <InfiniteLoading on:infinite={infiniteHandler} identifier={infiniteId} >
          <div slot="noMore">All data loaded</div>
        </InfiniteLoading>

blub ...

but nothing happens here...?

What am i missing?

Help request: how to do infinite tables

I have been trying to rework the hacker news example code to use tables, and am failing to get it to work. Is there any example I can look at, or is infinite scroll not suited to tables? Thanks,

Masonry - Is there a hook or callback I can use to re-fire masonry when new elements loaded?

Hi Skayo, thanks for this library! :)
I'm trying svelte-infinite-loading and tiny-virtual-list out, on a grid of Bootstrap column elements (flex columns, not CSS Grid, because i need to support more browsers).

I'd like to apply masonryjs to the elements and re-fire it when new elements are loaded. It seems like virtual list might provide an event to listen to, but I don't find it.

Or should I fire it on my own fetchMore for next page of data? It seems like there might be timing issues with that.

doc: Improve documentation for the `infiniteHandler`

This library is fantastic. Thank you for building this.

I thought I would write a suggestion to make it explicit the infiniteHandler working. I ran into an issue where I awaited for a promise inside the infiniteHandler and the scroll bar went into a scroll loop. It took hours of debugging to understand that we should not be awaiting inside the infiniteHandler and must return immediately. Hope will save some time for a future developer.

<script>
function infiniteHandler({ detail: { loaded, complete } }) {
    // ---------------------------------------------------
    // --  NOTE:  There is no `await` for this promise  --
    // ---------------------------------------------------
    fetch(`${api}&page=${page}`)
      .then(response => response.json())
      .then(data => {
          ...
    });
}
</script>

<VirtualList height={400} itemSize={42} itemCount={list.length}>
    ...            
    <div slot="footer">
        <InfiniteLoading on:infinite={infiniteHandler} />
    </div>
</VirtualList>

Hide or edit the noMore message

Hello,
I'd like to hide the noMore message (currently on No more data :) without edit the source. Is it possible?

Thanks for the plugin.

Is there any way to remove no more data message?

Hi, I'm currently using your work for shopping mall project.
And, I noticed that there is no given documents for customizing"no more data" message.
So I leaved an issue to ask you about some ways to customize those messages.

Thank you.

TypeError: Cannot read property 'offsetWidth' of null

Hello,
I'm getting this error, even that it is working nice, but idk how to fix it. I'm running sapper/firebase

Uncaught (in promise) TypeError: Cannot read property 'offsetWidth' of null
    at isVisible (InfiniteLoading.svelte:145)
    at attemptLoad (InfiniteLoading.svelte:232)
    at scrollHandler (InfiniteLoading.svelte:225)
    at InfiniteLoading.svelte:308

<InfiniteLoading> is not a valid SSR component.

Hello, I am not finding a way to overcome this error.

"You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a ."

Help appreciated,
Thank you!

Getting warning for this package after upgrading to sveltekit 2

9:29:01 AM [vite-plugin-svelte] WARNING: The following packages have a svelte field in their package.json but no exports condition for svelte.

[email protected]

Please see https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#missing-exports-condition for details.

The recommended fix is found here https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#missing-exports-condition

// package.json
  "files": ["dist"],
  "svelte": "dist/index.js",
+ "exports": {
+   ".": {
+     "svelte": "./dist/index.js"
+   }
  }

Typescript types declaration

Hey there. In case you're interested, I created a small declaration file for Typescript types for this library for my own use.

declare module "svelte-infinite-loading" {
	export interface InfiniteLoadingProps {
		distance?: number
		spinner?: "default" | "spiral" | "circles" | "bubbles" | "wavedots"
		direction?: "top" | "bottom"
		forceUseInfiniteWrapper?: boolean | string
		identifier?: any
	}

	export default class {
		$$prop_def: InfiniteLoadingProps
	}
}

If you add it to the files shipped to npm that would allow typescript users to get type information.
I'm just sharing it here in case that might interest you, but feel free to close this issue if you don't care :)

Cheers!

Enable CodeQL

Enable CodeQL in the settings after releasing 2.0.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.