Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 56aa93a

Browse files
committed
Update
1 parent 04a76a8 commit 56aa93a

File tree

13 files changed

+183
-114
lines changed

13 files changed

+183
-114
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017-present, stackjie
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 112 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,113 @@
1-
# Vue-Super-Scroll
2-
A pull to refresh and lnfinite scroll component for vue.js
1+
# Vue-Pull-To
2+
A pull to refresh and load more and an infinite scroll of the vue.js component.
33

4-
working~
4+
一个集成了下拉刷新、上拉加载、无限滚动加载的Vue组件。
5+
6+
[![GitHub issues](https://img.shields.io/github/issues/stackjie/vue-pull-to.svg)](https://github.com/stackjie/vue-pull-to/issues)
7+
[![GitHub stars](https://img.shields.io/github/stars/stackjie/vue-pull-to.svg)](https://github.com/stackjie/vue-pull-to/stargazers)
8+
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/stackjie/vue-pull-to/master/LICENSE)
9+
[![npm](https://img.shields.io/npm/v/vue-pull-to.svg)](https://www.npmjs.com/package/vue-pull-to)
10+
11+
## Examples
12+
13+
14+
## Installation
15+
```
16+
npm install vue-pull-to --save
17+
```
18+
19+
## Use Setup
20+
``` vue
21+
<template>
22+
<div>
23+
<pull-to :top-load-method="refresh">
24+
<ul>
25+
<li>item</li>
26+
<li>item</li>
27+
<li>item</li>
28+
<li>item</li>
29+
<li>item</li>
30+
<li>item</li>
31+
<li>item</li>
32+
<li>item</li>
33+
</ul>
34+
</pull-to>
35+
</div>
36+
</template>
37+
38+
<script>
39+
import PullTo from 'vue-pull-to'
40+
41+
export default {
42+
name: 'example',
43+
components: {
44+
PullTo
45+
},
46+
methods: {
47+
refresh(loaded) {
48+
setTimeout(() => {
49+
this.dataList.reverse();
50+
loaded('done');
51+
}, 2000);
52+
}
53+
}
54+
}
55+
</script>
56+
```
57+
组件会默认占据父元素的百分之百高度。props `top-load-method`和`bottom-load-method`会默认传进一个`loaded`参数,该参数是一个改变组件加载状态的函数,必须调用一次`loaded`不然组件就会一直处于加载状态,如果执行`loaded('done')`组件内部状态就会变成成功加载的状态,`loaded('fail')`为失败。
58+
59+
[更多使用示例请参考Examples的代码](https://github.com/stackjie/vue-pull-to/tree/master/examples)
60+
61+
## API Docs
62+
63+
### props
64+
| 属性 | 说明 | 类型 | 默认值 |
65+
| --- | --- | --- | --- |
66+
| distance-index | 滑动的阀值(值越大滑动的速度越慢) | Number | 2 |
67+
| top-block-height | 顶部在滚动容器外的块级元素区域高度 | Number | 50 |
68+
| bottom-block-height | 底部在滚动容器外的块级元素区域高度 | Number | 50 |
69+
| top-load-method | 顶部下拉时执行的方法 | Function | |
70+
| bottom-load-method | 底部上拉时执行的方法 | Function | |
71+
| is-throttle | 是否截流`top-pull``bottom-pull`自定义事件的触发以保证性能 | Boolean | true |
72+
| top-config | 滚动容器顶部信息的一些配置 | Object | 默认配置 |
73+
| bottom-config | 滚动容器底部信息的一些配置 | Object | 默认配置 |
74+
75+
`topConfig``bottomConfig`可配置的选项和默认配置项的值
76+
``` javascript
77+
const TOP_DEFAULT_CONFIG = {
78+
pullText: '下拉刷新', // 下拉时显示的文字
79+
triggerText: '释放更新', // 下拉到触发距离时显示的文字
80+
loadingText: '加载中...', // 加载中的文字
81+
doneText: '加载完成', // 加载完成的文字
82+
failText: '加载失败', // 加载失败的文字
83+
loadedStayTime: 400, // 加载完后停留的时间ms
84+
stayDistance: 50, // 触发刷新后停留的距离
85+
triggerDistance: 70 // 下拉刷新触发的距离
86+
};
87+
88+
const BOTTOM_DEFAULT_CONFIG = {
89+
pullText: '上拉加载',
90+
triggerText: '释放更新',
91+
loadingText: '加载中...',
92+
doneText: '加载完成',
93+
failText: '加载失败',
94+
loadedStayTime: 400,
95+
stayDistance: 50,
96+
triggerDistance: 70
97+
};
98+
```
99+
### slots
100+
| 名称 | 说明 | scope |
101+
| --- | --- | --- |
102+
| default | 默认slot滚动容器的内容 |
103+
| top-block | 滚动容器外顶部的内容(支持作用域slot需用`template`标签加上`scope`属性)| `state`:当前的状态、`state-text`:状态对应的文本 |
104+
| bottom-block | 滚动容器外底部的内容(支持作用域slot需用`template`标签加上`scope`属性)| `state`:当前的状态、`state-text`:状态对应的文本 |
105+
106+
### events
107+
| 事件名 | 说明 |
108+
| --- | --- |
109+
| top-state-change | 顶部状态发生了改变时触发,第一个参数为当前的状态 |
110+
| bottom-state-change | 底部状态发生了改变时触发,第一个参数为当前的状态 |
111+
| top-pull | 下拉时触发,第一个参数为当前拉动的距离值,默认会被截流,可配置props `isThrottle`来实时触发 |
112+
| bottom-pull | 上拉时触发,第一个参数为当前拉动的距离值,默认会被截流,可配置props `isThrottle`来实时触发 |
113+
| infinite-scroll | 当滚动容器滚动到底部时触发 |

build/base.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ function resolve (dir) {
88
module.exports = {
99
entry: './src/index.js',
1010
output: {
11-
library: 'VueEnhancedScroll',
11+
library: 'VuePullTo',
1212
libraryTarget: 'umd',
13-
filename: 'vue-enhanced-scroll.js',
13+
filename: 'vue-pull-to.js',
1414
path: resolve('dist')
1515
},
1616
plugins: [

examples/components/AppHeader.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<header class="app-header">
3-
<!--<i class="icon-back" v-show="isBack"></i>-->
4-
<h2>enhanced-scroller-examples</h2>
3+
<h2>vue-pull-to-examples</h2>
54
</header>
65
</template>
76

examples/pages/BounceScroll.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<enhanced-scroller>
2+
<pull-to>
33
<ul class="list">
44
<li>
55
(=゚ω゚)ノ
@@ -92,19 +92,19 @@
9292
(╭ ̄3 ̄)╭♡
9393
</li>
9494
</ul>
95-
</enhanced-scroller>
95+
</pull-to>
9696
</template>
9797

9898
<style scoped rel="stylesheet/less" lang="less">
9999
</style>
100100

101101
<script type="text/babel">
102-
import EnhancedScroller from '@/vue-enhanced-scroller';
102+
import PullTo from '@/vue-pull-to';
103103
104104
export default {
105105
name: 'bounce-scroll',
106106
components: {
107-
EnhancedScroller
107+
PullTo
108108
}
109109
};
110110
</script>

examples/pages/Home.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<use xlink:href="#icon-face-20"></use>
88
</svg>
99
</div>
10-
<enhanced-scroller class="scroller-view">
10+
<pull-to class="scroller-view">
1111
<ul class="list">
1212
<li>
1313
<router-link href="/bounce-scroll">
@@ -42,7 +42,7 @@
4242
</router-link>
4343
</li>
4444
</ul>
45-
</enhanced-scroller>
45+
</pull-to>
4646
</section>
4747
</template>
4848

@@ -112,14 +112,14 @@
112112
</style>
113113

114114
<script type="text/babel">
115-
import EnhancedScroller from '@/vue-enhanced-scroller';
115+
import PullTo from '@/vue-pull-to';
116116
import RouterLink from '../components/RouterLink';
117117
118118
export default {
119119
name: 'home',
120120
components: {
121121
RouterLink,
122-
EnhancedScroller
122+
PullTo
123123
}
124124
};
125125
</script>

examples/pages/InfiniteScroll.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<enhanced-scroller
2+
<pull-to
33
@infinite-scroll="loadmore">
44
<ul class="list">
55
<li v-for="item in dataList">
@@ -13,7 +13,7 @@
1313
</svg>
1414
加载中...
1515
</div>
16-
</enhanced-scroller>
16+
</pull-to>
1717
</template>
1818

1919
<style scoped rel="stylesheet/less" lang="less">
@@ -39,12 +39,12 @@
3939
</style>
4040

4141
<script type="text/babel">
42-
import EnhancedScroller from '@/vue-enhanced-scroller';
42+
import PullTo from '@/vue-pull-to';
4343
4444
export default {
4545
name: 'infinite-scroll',
4646
components: {
47-
EnhancedScroller
47+
PullTo
4848
},
4949
data() {
5050
return {

examples/pages/SimplePullToLoadMore.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<enhanced-scroller
2+
<pull-to
33
:bottom-load-method="loadmore"
44
@bottom-state-change="stateChange">
55
<ul class="list">
@@ -20,7 +20,7 @@
2020
{{ props.stateText }}
2121
</div>
2222
</template>
23-
</enhanced-scroller>
23+
</pull-to>
2424
</template>
2525

2626
<style scoped rel="stylesheet/less" lang="less">
@@ -50,12 +50,12 @@
5050
</style>
5151

5252
<script type="text/babel">
53-
import EnhancedScroller from '@/vue-enhanced-scroller';
53+
import PullTo from '@/vue-pull-to';
5454
5555
export default {
5656
name: 'simple-pull-to-loadmore',
5757
components: {
58-
EnhancedScroller
58+
PullTo
5959
},
6060
data() {
6161
return {
@@ -84,8 +84,6 @@
8484
} else if (state === 'loaded-done') {
8585
this.iconLink = '#icon-finish';
8686
}
87-
88-
console.log(this.iconLink);
8987
}
9088
}
9189
};

examples/pages/SimplePullToRefresh.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<enhanced-scroller
2+
<pull-to
33
:top-load-method="refresh"
44
@top-state-change="stateChange">
55
<template slot="top-block" scope="props">
@@ -20,7 +20,7 @@
2020
{{ item }}
2121
</li>
2222
</ul>
23-
</enhanced-scroller>
23+
</pull-to>
2424
</template>
2525

2626
<style scoped rel="stylesheet/less" lang="less">
@@ -50,12 +50,12 @@
5050
</style>
5151

5252
<script type="text/babel">
53-
import EnhancedScroller from '@/vue-enhanced-scroller';
53+
import PullTo from '@/vue-pull-to';
5454
5555
export default {
5656
name: 'simple-pull-to-refresh',
5757
components: {
58-
EnhancedScroller
58+
PullTo
5959
},
6060
data() {
6161
return {

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "vue-enhanced-scroller",
2+
"name": "vue-pull-to",
33
"version": "0.0.1",
4-
"description": "A pull to refresh and an infinite scroll of the vue.js component",
4+
"description": "A pull to refresh and load more and an infinite scroll of the vue.js component",
55
"main": "src/index.js",
66
"scripts": {
77
"dev": "node ./build/dev-server.js",
@@ -10,14 +10,14 @@
1010
},
1111
"repository": {
1212
"type": "git",
13-
"url": "git+https://github.com/stackjie/vue-enhanced-scroller.git"
13+
"url": "git+https://github.com/stackjie/vue-pull-to.git"
1414
},
1515
"author": "stackjie",
1616
"license": "MIT",
1717
"bugs": {
18-
"url": "https://github.com/stackjie/vue-enhanced-scroller/issues"
18+
"url": "https://github.com/stackjie/vue-pull-to/issues"
1919
},
20-
"homepage": "https://github.com/stackjie/vue-enhanced-scroller#readme",
20+
"homepage": "https://github.com/stackjie/vue-pull-to#readme",
2121
"dependencies": {
2222
"vue": "^2.2.6"
2323
},

0 commit comments

Comments
 (0)