JarodMS

Mobile App Development with Ionic, Angular, and More!

Menu
  • Home
  • Mobile Apps
  • About Me
  • Contact Me
  • Diary
Menu

Ionic 3 – Using the VirtualScroll Component

Posted on July 9, 2018July 9, 2018 by Jarod

I’ve built a sample application using the basic ionic Conference App with some tweaks. You can find the source here: https://github.com/jarodms/ionic3-virtual-scroll

Once you’ve cloned/downloaded the source, run the following to see the example in action (go to the Speakers tab):

npm i

npm run ionic:serve

The example app has the following:

  1. Tabs
  2. Sidemenu
  3. Version number at the bottom of the side menu
  4. Virtual Scroll
  5. 100 Speakers in the conference data.json file

 

Take a look in 'src/pages/speaker-list/speaker-list.html' for the example of using a VirtualScroll Component. You’ll see I have:

  1. <ion-list> as a child of <ion-content>
    1. <ion-list> sets the property [virtualScroll] to my array of speakers
  2. approxItemHeight is set to 85px. After deciding the pieces of data I wanted in each item, I used a tool to determine the number of pixels that I think I need. The default is 40px, so if you can get this number more accurate (“if significantly larger than the default”) then it will help with rendering.
  3. <ion-item> as a child of <ion-list>
    1. <ion-item> uses an item template with the *virtualItem property
  4. The children of <ion-item> are the various fields of a speaker that I want to display

 

So here’s what happens…

When the view is rendered, a small subset of items will be rendered, not the entire array of speakers. How do you know? Open your developer tools or inspect one of the items in the view. As you scroll down you will see the number of elements in the DOM under <ion-list> stay approximately the same; however the content of the items changes as you scroll. Nice!

 

For more options and usage of VirtualScroll, see the official Ionic documentation: https://ionicframework.com/docs/api/components/virtual-scroll/VirtualScroll/

Please follow:
error
Tweet
0

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Newsletter

Signup with your email address to receive news and updates.

Search

Recent Posts

  • Not able to call REST API on Android, but it works with iOS and Web App
  • Ionic – the platform was not ready when I was trying to get the location
  • My Dividend Meter
  • Angular app using Node, JSON server, NG-Bootstrap, and NgRx
  • LoadingController example showing “Loading…” message
  • Adding the Version Number in your app
  • PhoneGap Build – Config File
  • Example Angular 8 with NgRx and Redux DevTools
  • Update an Ionic4/Angular7 app to use Angular 8
  • Ionic 4 and Angular with PouchDB

Need Help?

I’m available for Ionic and Angular contract work. Contact me to get started.

My Links

All my apps on Google Play Store
All my apps on Apple App Store
GitHub
LinkedIn

Archives

  • October 2020
  • April 2020
  • March 2020
  • November 2019
  • October 2019
  • August 2019
  • November 2018
  • August 2018
  • July 2018

Categories

  • Angular
  • Beginner
  • Ionic
  • Ionic Component
  • PhoneGap Build
  • Uncategorized
  • Visual Notification

Available for Angular and Ionic freelance work including custom app development.

Tags

Angular AuthGuard component Custom Icon Firebase Font Awesome Geolocation Google Cloud Functions icons ionic3 Ionic4 iOS NgRx PhoneGap Build tabs VirtualScroll
© 2026 JarodMS | WordPress Theme by Superbthemes