Mobile-friendly List Scroller For Vue – horizontal-list

Install & Download:

# Yarn
$ yarn add vue-horizontal-list
# NPM
$ npm install vue-horizontal-list --save

Description:

A responsive, mobile-friendly, touch-enabled list scroller for scrolling through posts, articles, images, quotes just like a carousel.

How to use it:

1. Import the vue-horizontal-list component.

import Vue from 'vue';
import VueHorizontalList from '@/vue-horizontal-list.vue';

2. Add the component to the app template.

<vue-horizontal-list :items="items" :options="options">
  <template v-slot:default="{item}">
    <div class="item">
      <h5>{{item.title}}</h5>
      <p>{{item.content}}</p>
    </div>
  </template>
</vue-horizontal-list>

3. Render the vue-horizontal-list on the app.

export default Vue.extend({
  name: 'Name',
  components: {
    VueHorizontalList
  },
  data() {
    return {
      options: {
        responsive: [
          {end: 576, size: 1}, 
          {start: 576, end: 768, size: 2},
          {start: 768, end: 992, size: 3},
          {size: 4}
        ],
        list: {
          // 1200 because @media (min-width: 1200px) and therefore I want to switch to windowed mode
          windowed: 1200,
          
          // Because: #app {padding: 80px 24px;}
          padding: 24
        }
      },  
      items: [
        {title: 'Item 0', content: 'Content item with description'},
      ]
    }
  }
});

4. All default options.

item: {
  // css class to inject into each individual item
  class: '',
  // padding between each item
  padding: 12 
},
list: {
  // css class for the parent of item
  class: '', 
  // maximum width of the list it can extend to before switching to windowed mode, basically think of the bootstrap container max-width
  // windowed is used to toggle between full-screen mode and container mode
  windowed: 1200,
  // padding of the list, if container < windowed what is the left-right padding of the list
  // during full-screen mode the padding will added to left & right to centralise the item
  padding: 24
},
responsive: [
  // responsive breakpoints to calculate how many items to show in the list at each width interval
  // it will always fall back to these: 
  {end: 576, size: 1},
  {start: 576, end: 768, size: 2},
  {start: 768, end: 992, size: 3},
  {start: 992, end: 1200, size: 4},
  {start: 1200, size: 5}
],
navigation: {
  // when to show navigation
  start: 992,
  color: '#000'
}

Preview:

Mobile-friendly List Scroller For Vue - horizontal-list

Changelog:

v1.2.1 (12/10/2020)

  • Fix setInterval error

v1.2.0 (11/13/2020)

  • Fix the position evaluating
  • Implemented the autoplay feature
  • Fixed navigation not center aligned @fuxingloh
  • Implement new position evaluating when scrolling
  • Upgrade and bug fix @fuxingloh
  • Bump lodash from 4.17.15 to 4.17.19
  • Fixed SSR support due to regression bug.
  • Fixed regression error
  • Added smoothscroll-polyfill to fix safari and edge smooth scrolling

11/12/2020

  • v1.1.0: Slots for start/end and options.position.start

11/07/2020

  • v1.1.0: Implemented the autoplay feature

11/04/2020

  • v1.0.13: Fixed navigation not center aligned

07/22/2020

  • v1.0.12: Fixed falsely integer zero issue with babel nullish coalescing feature

Add Comment