0.2.0 • Published 3 years ago

vue3-waterfall v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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="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

AttributeDescriptionTypeDefault
widthContainer width (px), default is 100% relative parent element width.Number-
heightContainer 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-
listRequired Data used to render the waterfall stream Each array element is an object and must have imgSrc attribute.Array[]
colscolumns, cannot use with colWidth attribute.Number0
colWidthcolumn width(px),cannot use with cols attribute.Number240
gapgap width (px)Number15
nomorewhether has more dataBooleanfalse
footerHeightfooter height(px), it can show other info what u want.Number0
scrollDisabledDisable scrollingBooleanfalse
scrollDelayScrolling throttle (ms)200
scrollDistancetrigger distance (px)Number0
scrollImmediateWhether to execute the loading method immediately, in case the content cannot be filled up in the initial state.Booleantrue

Slots

NameDescription
defaultDefault slot, Custom content for image.
footerCustom content for footer.
loadingCustom content for loading status.
nomoreCustom content for no more data.

License

Released under the MIT License.

0.2.0

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago