# vue-waterfall-easy 2.x
1. This is a vue component that contains waterfall flow layout and infinite scroll loading
2. Compared to other implementations,there is no need to specify the width and height of the image in the returned data
3. It is because of the second item that the image is preloaded and then layout
4. Responsive layout,adapt mobile
5. Simple to use
## [中文文档](https://github.com/lfyfly/vue-waterfall-easy/blob/master/README-CN.md)
## [Demo](https://lfyfly.github.io/vue-waterfall-easy/demo/)
## [code of demo](https://github.com/lfyfly/vue-waterfall-easy/blob/master/src/App.vue)
## [update list](https://github.com/lfyfly/vue-waterfall-easy/issues/8)
## [github](https://github.com/lfyfly/vue-waterfall-easy)
## 1. Usage
### 1.1 Installation
```
npm install vue-waterfall-easy --save
```
### 1.2 es6 import
```js
import vueWaterfallEasy from 'vue-waterfall-easy'
```
```js
export default {
name: 'app',
components: {
vueWaterfallEasy
}
}
```
### 1.3 scripts import
[download vueWaterfallEasy.js](https://github.com/lfyfly/vue-waterfall-easy/blob/master/src/vue-waterfall-easy/script/vueWaterfallEasy.js)
```html
```
```js
new Vue({
el: '#app',
components: {
vueWaterfallEasy
}
})
```
### 1.4 Supports require.js and sea.js module import
## 2. Basic example
html
```html
picture index: {{props.index}} {{props.value.info}}
**If it is fixed width, you must set the width prop **, not just its parent element set fixed width
height | Number\|String | - | Container height, the default unit `px` for the value of the `Number` type, the unit can be specified when the value is the type of `String`
**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**
gap | Number | 20 | [Pc] space between pictures(px)
mobileGap | Number | 8 | [Mobile] space between pictures(px)
imgsArr | Array | [] | **required**
Data used to render the waterfall stream
Each array element is an object and must have `src` and `href` attributes.
The `src` attribute represents the SRC attribute of the picture
The `href` attribute represents the link to click to jump
**if your key is not `src` and `href`, you can use the two properties of `srcKey` and `hrefKey` to do the key value replacement.**
srcKey | String | 'src' | When the key value of your picture address is not `src`, you can use this property to replace it.
hrefKey | String | 'href' | When the key value of your picture address is not `href`, you can use this property to replace it.
imgWidth | Number | 240 | The width of the picture(px)
maxCols | Number | 5 | Waterfall shows the maximum number of columns
linkRange | String | 'card' | Identify click to trigger jump link range
value:
'card' Whole card range
'img' image range
'custom' Customize the link range through slots
isRouterLink | Boolean | false | Render the a tag when the value is false
Render the router-link component when the value is true
reachBottomDistance | Number | 0 | The distance(px) from the bottom of the container when the scrolling triggers the scrollReachBottom event
loadingDotCount | Number | 3 | The number of default loading animation dots
loadingDotStyle | Object | null | The style object of the small dots in the default loading element
loadingTimeOut | Number | 500 | Preloading events less than 500ms milliseconds do not display loading animations,increasing the user experience
cardAnimationClass | String | 'default-card-animation' | the animation className for the card
enablePullDownEvent | Boolean | false | enable the drop-down event
## 4. Event
event name | description
---|---
scrollReachBottom | When the scroll bar scrolls to the bottom,it is used to trigger a request for new image data
preloaded | Trigger every time image preloading is completed
click | Trigger when the card is clicked,look at an example under the table
imgError | Trigger when img load error
pullDownMove | The mobile terminal takes effect, touches the pull-down event, and the first parameter can obtain the Y-axis moving distance difference, which is often used for pull-down refresh.
pullDownEnd | The mobile terminal takes effect, and the touch pull-down event is raised by the finger, which is often used for pull-down refresh.
click event demo
```html