Skip to content

Commit 7520eb0

Browse files
author
dengwen49
committed
添加main目录
1 parent 469f5c1 commit 7520eb0

File tree

7 files changed

+778
-0
lines changed

7 files changed

+778
-0
lines changed

main/README.md

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
2+
3+
4+
#### [中文版文档](https://github.com/AwesomeDevin/vue-waterfall2/blob/master/CHINESE-README.md)
5+
# vue-waterfall2
6+
1. auto adaption for width and height
7+
2. High degree of customization
8+
3. support lazy load(attribute with `lazy-src`)
9+
10+
![The demo on mobile device](https://raw.githubusercontent.com/AwesomeDevin/vue-waterfall2/master/src/assets/gifhome_240x514_17s.gif)
11+
12+
13+
If you have some questions,welcome to describe issues、suggestions;Thank you for your Star !
14+
[Welcome to my blog !!!](https://github.com/AwesomeDevin/blog)
15+
16+
17+
## Demo
18+
[Common Demo](http://47.105.188.15:3001/)
19+
[Lazyload Demo](http://47.105.188.15:3001/#/list)
20+
[Code Demo](https://codesandbox.io/embed/vue-template-99ps6)
21+
22+
23+
24+
25+
26+
[GITHUB](https://github.com/Rise-Devin/vue-waterfall2)
27+
```
28+
npm i
29+
npm run dev
30+
```
31+
32+
## Installation
33+
```
34+
npm i vue-waterfall2@latest --save
35+
```
36+
37+
## <waterfall> Props
38+
Name | Default | Type | Desc
39+
-------- | -------- | -------- | --------
40+
height | null | Number | height of container
41+
col | 2 | Number | The number of column
42+
width | null | Number | The width of each column
43+
gutterWidth | 10 | Number | The value of margin
44+
data | [] | Array | data
45+
isTransition | true | Boolean | load image with transition
46+
lazyDistance | 300 | Number | The distance of image lazy loading
47+
loadDistance | 300 | Number | The distance of loadmore
48+
49+
## Lazy Load
50+
For images that need to be loaded lazily, the 'lazy-src' attribute needs to be used
51+
```html
52+
<waterfall :col='col' :data="data" >
53+
<template>
54+
<img v-if="item.img" :lazy-src="item.img" alt="load error" />
55+
</template>
56+
</waterfall>
57+
```
58+
59+
## <waterfall> Events
60+
Name | Data | Desc
61+
-------- | --- | --------
62+
loadmore | - | Scroll to the bottom to trigger on PC / pull up to trigger on Mobile
63+
scroll | obj | Scroll to trigger and get the infomation of scroll
64+
finish | - | finish render
65+
66+
## $waterfall API
67+
```
68+
this.$waterfall.forceUpdate() //forceUpdate
69+
```
70+
71+
## Usage
72+
Notes:
73+
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).
74+
2. Use the parent component of 'waterfall' if there is a problem with the style, remove CSS `scoped` and try it
75+
##### main.js
76+
```javascript
77+
import waterfall from 'vue-waterfall2'
78+
Vue.use(waterfall)
79+
```
80+
##### app.vue
81+
```javascript
82+
<template>
83+
<div class="container-water-fall">
84+
<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>
85+
86+
<waterfall :col='col' :width="itemWidth" :gutterWidth="gutterWidth" :data="data" @loadmore="loadmore" @scroll="scroll" >
87+
<template >
88+
<div class="cell-item" v-for="(item,index) in data">
89+
<div class="item-body">
90+
<div class="item-desc">{{item.title}}</div>
91+
<div class="item-footer">
92+
<div class="avatar" :style="{backgroundImage : `url(${item.avatar})` }"></div>
93+
<div class="name">{{item.user}}</div>
94+
<div class="like" :class="item.liked?'active':''" >
95+
<i ></i>
96+
<div class="like-total">{{item.liked}}</div>
97+
</div>
98+
</div>
99+
</div>
100+
</div>
101+
</template>
102+
</waterfall>
103+
104+
</div>
105+
</template>
106+
107+
108+
/*
109+
notes:
110+
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).
111+
2. Use the parent component of 'waterfall' if there is a problem with the style, remove CSS 'scoped' and try it
112+
*/
113+
114+
import Vue from 'vue'
115+
export default{
116+
data(){
117+
return{
118+
data:[],
119+
col:5,
120+
}
121+
},
122+
computed:{
123+
itemWidth(){
124+
return (138*0.5*(document.documentElement.clientWidth/375)) #rem to layout, Calculate the value of width
125+
},
126+
gutterWidth(){
127+
return (9*0.5*(document.documentElement.clientWidth/375)) #rem to layout, Calculate the value of margin
128+
}
129+
},
130+
methods:{
131+
scroll(scrollData){
132+
console.log(scrollData)
133+
},
134+
switchCol(col){
135+
this.col = col
136+
console.log(this.col)
137+
},
138+
loadmore(index){
139+
this.data = this.data.concat(this.data)
140+
}
141+
}
142+
}
143+
```

main/bus.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _vue = require('vue');
8+
9+
var _vue2 = _interopRequireDefault(_vue);
10+
11+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12+
13+
var Bus = new _vue2.default();
14+
exports.default = Bus;

main/es5/bus.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _vue = require('vue');
8+
9+
var _vue2 = _interopRequireDefault(_vue);
10+
11+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12+
13+
var Bus = new _vue2.default();
14+
exports.default = Bus;

main/es5/index.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _bus = require('./bus.js');
8+
9+
var _bus2 = _interopRequireDefault(_bus);
10+
11+
var _waterfall = require('./waterfall.vue');
12+
13+
var _waterfall2 = _interopRequireDefault(_waterfall);
14+
15+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16+
17+
var Index = {
18+
install: function install(Vue) {
19+
if (this.installed) {
20+
return;
21+
}
22+
this.installed = true;
23+
Vue.component('waterfall', _waterfall2.default);
24+
Vue.prototype.$waterfall = {
25+
resize: function resize() {
26+
_bus2.default.$emit('resize');
27+
},
28+
mix: function mix() {
29+
_bus2.default.$emit('mix');
30+
}
31+
};
32+
}
33+
};
34+
exports.default = Index;

main/index.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _bus = require('./bus.js');
8+
9+
var _bus2 = _interopRequireDefault(_bus);
10+
11+
var _waterfall = require('./waterfall.vue');
12+
13+
var _waterfall2 = _interopRequireDefault(_waterfall);
14+
15+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16+
17+
var Index = {
18+
install: function install(Vue) {
19+
if (this.installed) {
20+
return;
21+
}
22+
this.installed = true;
23+
Vue.component('waterfall', _waterfall2.default);
24+
Vue.prototype.$waterfall = {
25+
forceUpdate: function forceUpdate() {
26+
_bus2.default.$emit('forceUpdate');
27+
},
28+
mix: function mix() {
29+
_bus2.default.$emit('mix');
30+
}
31+
};
32+
}
33+
};
34+
exports.default = Index;

main/package.json

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"_args": [
3+
[
4+
"vue-waterfall2@1.9.1",
5+
"D:\\projects\\act\\proj\\2018\\1112_findv2"
6+
]
7+
],
8+
"_from": "vue-waterfall2@1.9.1",
9+
"_id": "vue-waterfall2@1.9.1",
10+
"_inBundle": false,
11+
"_integrity": "sha512-fMJq9LJwb6/0AciO7IqQNZb+fEkzpkyzOhugT+POndGAEGWpallLw6yDc0ZfKJ/AmStD+gPyvSLv8UY4KBnfEg==",
12+
"_location": "/vue-waterfall2",
13+
"_phantomChildren": {},
14+
"_requested": {
15+
"type": "range",
16+
"registry": true,
17+
"raw": "vue-waterfall2@^1.9.1",
18+
"name": "vue-waterfall2",
19+
"escapedName": "vue-waterfall2",
20+
"rawSpec": "^1.9.1",
21+
"saveSpec": null,
22+
"fetchSpec": "^1.9.1"
23+
},
24+
"_requiredBy": [
25+
"#DEV:/"
26+
],
27+
"_resolved": "https://registry.npm.taobao.org/vue-waterfall2/download/vue-waterfall2-1.9.1.tgz",
28+
"_shasum": "0793f2abead08383d15e072880017858cbdf3223",
29+
"_spec": "vue-waterfall2@^1.9.1",
30+
"_where": "E:\\projects\\work\\vue-waterfall",
31+
"author": {
32+
"name": "daivonup@gmail.com"
33+
},
34+
"bugs": {
35+
"url": "https://github.com/Rise-Devin/vue-waterfall2/issues"
36+
},
37+
"bundleDependencies": false,
38+
"dependencies": {
39+
"babel-runtime": "^6.26.0",
40+
"regenerator-runtime": "^0.13.1"
41+
},
42+
"deprecated": false,
43+
"description": "vue plugin for waterfall",
44+
"devDependencies": {
45+
"babel-polyfill": "^6.26.0",
46+
"babel-preset-es2015": "^6.24.1",
47+
"vue": "^2.5.2"
48+
},
49+
"homepage": "https://github.com/Rise-Devin/vue-waterfall2#readme",
50+
"keywords": [
51+
"waterfall",
52+
"vue"
53+
],
54+
"license": "MIT",
55+
"main": "index.js",
56+
"name": "vue-waterfall2",
57+
"repository": {
58+
"type": "git",
59+
"url": "git+https://github.com/Rise-Devin/vue-waterfall2.git"
60+
},
61+
"scripts": {
62+
"test": "echo \"Error: no test specified\" && exit 1"
63+
},
64+
"version": "1.9.1",
65+
"__npminstall_done": "Mon Oct 14 2019 20:59:33 GMT+0800 (GMT+08:00)"
66+
}

0 commit comments

Comments
 (0)