Wednesday, 18 April, 2018 UTC


Summary

  • For this post, we’ll go without a plugin or package and we’re going to be writing a simple JavaScript function that fetches a new set of data when scrolled to the bottom of the browser window.
  • Before we start integrating the infinite scroll, let’s fetch and set some initial data on page load: – – It’s worth noting that it’s not recommended to make five services calls on load.
  • We’ll make use of the document object’s , properties and of window’s properties to determine if scroll as at the bottom: – – Inside this condition, let’s add a service method with Axios to fetch another random user from the Random User API.
  • This function makes a service call and adds a new random “user” to the array only when the user scrolls to the bottom of the page.
  • With each scroll to the bottom of the page, we fetch new data with Axios then push that data to an array.
Learn how to implement a simple infinite scroll for your Vue apps using nothing but some vanilla JavaScript and a simple Random User API.
@palashv2: Implementing an Infinite Scroll with Vue.js: #reactjs #javascript #react #ui #angularjs…
Infinite scrolls have their place on the web, but it aren’t for every website or application. They’re especially useful when you need to load large amounts of data or images when the user needs them rather than at all once. Social media outlets like Twitter, Facebook, and Instagram have popularized this over the years. Integrating your own infinite scroll on your website or application is easier than you might think.
This article is going to be using the Random User API. The API describes itself as “Like Lorem Ipsum, but for people”. It’s not only great for this implementation, but it’s also very useful for mocking up user profiles for future projects.
Before you start, create a new Vue.js project using the Vue CLI template. This example will be using Axios and MomentJS for data fetching and date formatting, respectively.
There are various npm packages for infinite scroll that you can use for your Vue app, but some of these may be overkill. For this post, we’ll go without a plugin or package and we’re going to be writing a simple JavaScript function that fetches a new set of data when scrolled to the bottom of the browser window.
Before we start integrating the infinite scroll, let’s fetch and set some initial data on page load:
It’s worth noting that it’s not recommended to make…
Implementing an Infinite Scroll with Vue.js ← Alligator.io