# vue-waterfall2 **Repository Path**: shuinger/vue-waterfall2 ## Basic Information - **Project Name**: vue-waterfall2 - **Description**: vue 自适应瀑布流插件,支持懒加载,使用方便 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-07-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # vue-waterfall2 1. auto adaption for width and height 2. High degree of customization 3. support lazy load(attribute with `lazy-load`) ## [中文版文档](https://github.com/AwesomeDevin/vue-waterfall2/blob/master/CHINESE-README.md) If you have some questions,welcome to describe issues、suggestions;Thank you for your Star ! [Welcome to my blog !!!](https://github.com/AwesomeDevin/blog) ![The demo on mobile device](https://raw.githubusercontent.com/AwesomeDevin/vue-waterfall2/master/src/assets/gifhome_240x514_17s.gif) ## Demo [Demo](http://47.105.188.15:3001/index.html) [GITHUB](https://github.com/Rise-Devin/vue-waterfall2) ``` npm i npm run dev ``` ## Installation ``` npm i vue-waterfall2@latest --save ``` ## Usage Notes: 1. attribute `gutterWidth` needs to be used together with `width` to be effective, otherwise it will be adaptive width (when using `rem` to layout, calculate the width after adaptation before passing the value). 2. Using the parent component of 'waterfall', the style tag does not allow the use of 'scoped', otherwise the style would have problems ##### main.js ```javascript import waterfall from 'vue-waterfall2' Vue.use(waterfall) ``` ##### app.vue(Scoped is not used for this component style) ```javascript /* notes: 1. attribute `gutterWidth` needs to be used together with `width` to be effective, otherwise it will be adaptive width (when using `rem` to layout, calculate the width after adaptation before passing the value). 2. Using the parent component of 'waterfall', the style tag does not allow the use of 'scoped', otherwise the style would have problems */ 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) } } } ``` ## Props Name | Default | Type | Desc -------- | -------- | -------- | -------- col | 2 | Number | the number of column width | null | Number | the value of width gutterWidth | 10 | Number | the value of margin data | [] | Array | data isTransition | true | Boolean | load image with transition ## Lazy Load For images that need to be loaded lazily, the 'lazy-src' attribute needs to be used ```javascript ``` ## Events Name | Data | Desc -------- | --- | -------- loadmore | null | 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 ## $waterfall API ``` this.$waterfall.forceUpdate() //forceUpdate ```