vue-waterfall2
Waterfall adaptive plugin for vue and support lazy load , so easy!
Last updated a month ago .
· Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vue-waterfall2 
SYNC missed versions from official npm registry.

中文版文档

vue-waterfall2

  1. auto adaption for width and height
  2. High degree of customization
  3. Swipe to the bottom to trigger on pc/android, pull up to trigger on ios
  4. Support lazy load(attribute with lazy-src)
  5. Easy to use, for PC/ios/android

The demo on mobile device

If you have some questions,welcome to describe issues、suggestions;Thank you for your Star !
Welcome to my blog !!!

Demo

Common Demo
Lazyload Demo
Code Demo

GITHUB

npm i 
npm run dev

Installation

 npm i vue-waterfall2@latest --save

<waterfall> Props

Name Default Type Desc
height null Number height of container
col 2 Number The number of column
width null Number The width of each column
gutterWidth 10 Number The value of margin
data [] Array data
isTransition true Boolean load image with transition
lazyDistance 300 Number The distance of image lazy loading
loadDistance 300 Number The distance of loadmore

Lazy Load

For images that need to be loaded lazily, the 'lazy-src' attribute needs to be used

<waterfall :col='col'   :data="data"     >
  <template>
     <img v-if="item.img" :lazy-src="item.img" alt="load error"  />
  </template>
</waterfall>

<waterfall> Events

Name Data Desc
loadmore - Scroll to the bottom to trigger on PC / pull up to trigger on Mobile
scroll obj Scroll to trigger and get the infomation of scroll
finish - finish render

$waterfall API

this.$waterfall.forceUpdate()   //forceUpdate

Usage

Notes:

  1. when using rem to layout, calculate the width after adaptation before passing the value.
  2. Use the parent component of 'waterfall' if there is a problem with the style, remove CSS scoped and try it
main.js
import waterfall from 'vue-waterfall2'
Vue.use(waterfall)
app.vue
<template>
  <div class="container-water-fall">
    <div><button  @click="loadmore">loadmore</button> <button @click="mix">mix</button> <button @click="switchCol('5')">5列</button> <button @click="switchCol('8')">8列</button> <button @click="switchCol('10')">10列</button> </div>

    <waterfall :col='col' :width="itemWidth" :gutterWidth="gutterWidth"  :data="data"  @loadmore="loadmore"  @scroll="scroll"  >
      <template >
        <div class="cell-item" v-for="(item,index) in data">
          <div class="item-body">
              <div class="item-desc">{{item.title}}</div>
              <div class="item-footer">
                  <div class="avatar" :style="{backgroundImage : `url(${item.avatar})` }"></div>
                  <div class="name">{{item.user}}</div>
                  <div class="like" :class="item.liked?'active':''" >
                      <i ></i>
                      <div class="like-total">{{item.liked}}</div>  
                  </div>
              </div>
          </div>
        </div>
      </template>
    </waterfall>
    
  </div>
</template>


/*
  notes:
  1. when using `rem` to layout, calculate the width after adaptation before passing the value.
  2. Use the parent component of 'waterfall' if there is a problem with the style, remove CSS 'scoped' and try it
*/

import Vue from 'vue'
	export default{
	    data(){
	        return{
	            data:[],
	            col:5,
	        }
	    },
	    computed:{
	      itemWidth(){  
	            return (138*0.5*(document.documentElement.clientWidth/375))  #rem to layout, Calculate the value of width 
	      },
	      gutterWidth(){
	            return (9*0.5*(document.documentElement.clientWidth/375)) #rem to layout, Calculate the value of margin 
	      }
	    },
	    methods:{
            scroll(scrollData){
                console.log(scrollData)
            },
	        switchCol(col){
	            this.col = col
	            console.log(this.col)
	      },
	      loadmore(index){
	            this.data = this.data.concat(this.data)
	      }
	    }
	}

Current Tags

  • 1.10.6                                ...           latest (a month ago)

75 Versions

  • 1.0.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.5                                ...           4 years ago
  • 1.0.6                                ...           4 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.8                                ...           4 years ago
  • 1.0.9                                ...           4 years ago
  • 1.0.10                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.3                                ...           4 years ago
  • 1.2.4                                ...           4 years ago
  • 1.2.5                                ...           4 years ago
  • 1.2.6                                ...           4 years ago
  • 1.2.7                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.4.1                                ...           4 years ago
  • 1.4.2                                ...           4 years ago
  • 1.4.3                                ...           4 years ago
  • 1.4.4                                ...           4 years ago
  • 1.5.0                                ...           4 years ago
  • 1.5.1                                ...           4 years ago
  • 1.5.2                                ...           4 years ago
  • 1.6.0                                ...           4 years ago
  • 1.6.1                                ...           4 years ago
  • 1.6.2                                ...           4 years ago
  • 1.6.4                                ...           4 years ago
  • 1.6.5                                ...           4 years ago
  • 1.7.1                                ...           4 years ago
  • 1.7.2                                ...           4 years ago
  • 1.7.3                                ...           4 years ago
  • 1.7.4                                ...           4 years ago
  • 1.7.5                                ...           4 years ago
  • 1.7.6                                ...           4 years ago
  • 1.7.7                                ...           4 years ago
  • 1.8.1                                ...           4 years ago
  • 1.8.2                                ...           4 years ago
  • 1.8.3                                ...           4 years ago
  • 1.8.4                                ...           4 years ago
  • 1.8.5                                ...           4 years ago
  • 1.8.6                                ...           4 years ago
  • 1.8.7                                ...           4 years ago
  • 1.8.8                                ...           4 years ago
  • 1.8.9                                ...           4 years ago
  • 1.8.10                                ...           3 years ago
  • 1.8.11                                ...           3 years ago
  • 1.8.12                                ...           3 years ago
  • 1.8.13                                ...           3 years ago
  • 1.8.14                                ...           3 years ago
  • 1.8.16                                ...           3 years ago
  • 1.8.17                                ...           3 years ago
  • 1.8.18                                ...           3 years ago
  • 1.8.19                                ...           3 years ago
  • 1.8.20                                ...           3 years ago
  • 1.8.21                                ...           3 years ago
  • 1.8.22                                ...           3 years ago
  • 1.9.1                                ...           3 years ago
  • 1.9.2                                ...           3 years ago
  • 1.9.3                                ...           3 years ago
  • 1.9.4                                ...           3 years ago
  • 1.9.5                                ...           3 years ago
  • 1.9.6                                ...           3 years ago
  • 1.10.1                                ...           2 years ago
  • 1.10.2                                ...           3 months ago
  • 1.10.3                                ...           3 months ago
  • 1.10.4                                ...           3 months ago
  • 1.10.5                                ...           3 months ago
  • 1.10.6                                ...           a month ago
Maintainers (1)
Dependencies (2)
Dev Dependencies (3)

Copyright © npmmirror.com | 浙ICP备15033595号-63 |