vue3-waterfall

A waterfall component build with Vue3、Typescript and Vite.
879 5
Install
npm install vue3-waterfall
Latest Version:0.2.0
Vue:3
License:MIT
Last Updated:Feb 25, 2024
Links: GitHub  ·  npm
Maintainer: ximolang

Vue3 Waterfall

A waterfall component build with Vue3、Typescript and Vite.

中文文档

Usage

Install

yarn add vue3-waterfall

// or

npm i vue3-waterfall --save

Import

<template>
  <waterfall
    :list="list"
    :cols="4"
    :footerHeight="60"
    :nomore="noMore"
    @preLoaded="loadedEnd"
    @scrollReachBottom="loadMore">
    <!-- Customize Image box -->
    <template v-slot:default="{ item }">
      <div class="imgbox">
        <img :src="https://raw.githubusercontent.com/seymoe/vue3-waterfall/HEAD/item.imgSrc" :alt="item.title">
      </div>
    </template>
    <!-- Customize footer -->
    <template v-slot:footer="{ item }">
      <span>{{ item.title }}</span>
    </template>
    <template v-slot:loading>
      <span>Loading...</span>
    </template>
    <template v-slot:nomore>
      <span>NoMore...</span>
    </template>
  </waterfall>
</template>

<script>
import { defineComponent } from 'vue'
import VueWaterfall from 'vue3-waterfall'

export default defineComponent({
  data() {
    return {
      list: [],
      noMore: false
    }
  },
  components: {
    VueWaterfall
  },
  methods: {
    loadMore() {
      console.log('Load More...')
      if (this.list.length >= 30) {
        this.noMore = true
      }
    },
    loadedEnd() {
      console.log('Images preload done.')
    }
  },
})
</script>

Attributes

Attribute Description Type Default
width Container width (px), default is 100% relative parent element width. Number -
height Container height (px), When you do not specify the height value, the default is relative to the height of the parent element 100%, then the parent element must have a height. Number -
list Required Data used to render the waterfall stream Each array element is an object and must have imgSrc attribute. Array []
cols columns, cannot use with colWidth attribute. Number 0
colWidth column width(px),cannot use with cols attribute. Number 240
gap gap width (px) Number 15
nomore whether has more data Boolean false
footerHeight footer height(px), it can show other info what u want. Number 0
scrollDisabled Disable scrolling Boolean false
scrollDelay Scrolling throttle (ms) 200
scrollDistance trigger distance (px) Number 0
scrollImmediate Whether to execute the loading method immediately, in case the content cannot be filled up in the initial state. Boolean true

Slots

Name Description
default Default slot, Custom content for image.
footer Custom content for footer.
loading Custom content for loading status.
nomore Custom content for no more data.

License

Released under the MIT License.

Related Packages

vue-waterfall2

waterfall adaptive plugin for vue and support lazy load , very easy!

23,328
v3-waterfall

一个 vue 3 的自适应瀑布流组件。

5,886 153
vite-plugin-vue2

Vite plugin for Vue2

1,474,659 618
@vue-vine/vite-plugin

Official Vite plugin for Vue Vine

95,680 1,442
vue2-waterfall

An AutoHeight Waterfall Component For Vue2

39,050 94

Version History

Version Released Vue License
0.2.0 ^3.1.1 MIT
0.1.9 ^3.1.1 MIT
0.1.8 ^3.1.1 MIT
0.1.7 ^3.1.1 MIT
0.1.6 ^3.1.1 MIT