DEV Community

Vasyl Pominchuk
Vasyl Pominchuk

Posted on

4

Infinite Scroll for Vue3. Yet another component.

Image description

vue-infinite-scroll is a super simple and lightweight package allowing you to implement infinite scroll for your project in a second.

Just type
npm i @vpominchuk/vue-infinite-scroll

and use it as:
<infinite-scroll :active="true" distance="50px" auto-load="true" @process="load" />

<infinite-scroll /> component has a few properties to change the behavior.

Properties

Property Type Description
active Boolean Enable / Disable Component
distance String Distance from the bottom side of the page when component fires @process event to load the content. "200px" is a good enough, but you can choose any other value.
auto-load Boolean Fire @process event on component mount

Event

Property Description
@process Callback function - fires when user scrolls to the bottom side of the page. Load a new portion of your content here.

Sample

Sample is available under dev folder.

To try the sample, create a new folder out of your project.
Install vue-infinite-scroll package and run npm run serve

mkdir vue-infinite-scroll-exampe
cd vue-infinite-scroll-exampe
npm i @vpominchuk/vue-infinite-scroll
cd node_modules/@vpominchuk/vue-infinite-scroll/
npm i
npm run serve
Enter fullscreen mode Exit fullscreen mode

If you are using Windows platform try
npm run serve-win

Open http://localhost:8080/ in your favorite browser

Remove node_modules inside @vpominchuk/vue-infinite-scroll/ after tests.

Github page:
https://github.com/vpominchuk/vue-infinite-scroll

Enjoy :)

Top comments (0)

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay