Skip to content

Commit

Permalink
v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wangdahoo committed Dec 20, 2016
1 parent 576d028 commit a4d8e79
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 63 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bower_components/
npm-debug.log

.idea/
.vscode/
43 changes: 14 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Vue Scroller ![version](https://img.shields.io/badge/release-%20v0.3.9%20-green.svg) ![vue](https://img.shields.io/badge/vue-%20v1.0%20-green.svg) ![gzip](https://img.shields.io/badge/gzip-%2010k%20-green.svg)
# Vue Scroller ![version](https://img.shields.io/badge/release-%20v0.4.0%20-green.svg) ![vue](https://img.shields.io/badge/vue-%20v1.0%20-green.svg) ![gzip](https://img.shields.io/badge/gzip-%2010k%20-green.svg)

[Vue Scroller](https://github.com/wangdahoo/vue-scroller) is a foundational component of [Vonic](https://github.com/wangdahoo/vonic) UI.
In purpose of smooth scrolling, pull to refresh and infinite loading.

## [Demo](https://wangdahoo.github.io/vue-scroller/)

## Change Logs
- v0.4.0
add finishInfinite method for better 'no more data' support.
remove $scroller
- v0.3.9
add getPosition method for scroller instance.
- v0.3.8
Expand Down Expand Up @@ -59,10 +62,7 @@ module.exports = {
#### Step 3: copy codes below to overwrite App.vue
```vue
<template>
<scroller delegate-id="myScroller"
:on-refresh="refresh"
:on-infinite="loadMore"
v-ref:my_scroller>
<scroller :on-refresh="refresh" :on-infinite="infinite" v-ref:my_scroller>
<div v-for="(index, item) in items" @click="onItemClick(index, item)"
class="row" :class="{'grey-bg': index % 2 == 0}">
{{ item }}
Expand All @@ -85,56 +85,42 @@ module.exports = {
},
ready() {
for (let i = 1; i <= 20; i++) {
this.items.push(i + ' - keep walking, be 2 with you.')
}
this.top = 1
this.bottom = 20
setTimeout(() => {
/* 下面2种方式都可以调用 resize 方法 */
// 1. use scroller accessor
$scroller.get('myScroller').resize()
// 2. use component ref
// this.$refs.my_scroller.resize()
this.$refs.my_scroller.resize()
})
},
methods: {
refresh() {
setTimeout(() => {
let start = this.top - 1
for (let i = start; i > start - 10; i--) {
this.items.splice(0, 0, i + ' - keep walking, be 2 with you.')
}
this.top = this.top - 10;
/* 下面3种方式都可以调用 finishPullToRefresh 方法 */
/* 下面2种方式都可以调用 finishPullToRefresh 方法 */
// this.$broadcast('$finishPullToRefresh')
$scroller.get('myScroller').finishPullToRefresh()
// this.$refs.my_scroller.finishPullToRefresh()
this.$refs.my_scroller.finishPullToRefresh()
}, 1500)
},
loadMore() {
infinite() {
setTimeout(() => {
let start = this.bottom + 1
for (let i = start; i < start + 10; i++) {
this.items.push(i + ' - keep walking, be 2 with you.')
}
this.bottom = this.bottom + 10;
setTimeout(() => {
$scroller.get('myScroller').resize()
this.$refs.my_scroller.finishInfinite()
})
}, 1500)
},
Expand All @@ -143,10 +129,8 @@ module.exports = {
console.log(index)
}
}
}
</script>
<style>
html, body {
margin: 0;
Expand Down Expand Up @@ -185,9 +169,10 @@ $ npm run dev

## Scroller instance API
#### Methods
- resize :Void
- triggerPullToRefresh :Void
- Void finishPullToRefresh :Void
- resize() :Void
- triggerPullToRefresh() :Void
- finishPullToRefresh() :Void
- finishInfinite(isNoMoreData :Boolean) :Void
- scrollTo(x:Integer, y:Integer, animate:Boolean) :Void
- scrollBy(x:Integer, y:Integer, animate:Boolean) :Void
- getPosition :Object
Expand Down
32 changes: 0 additions & 32 deletions bower.json

This file was deleted.

2 changes: 1 addition & 1 deletion dist/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h1 class="title">Refresh & Infinite</h1>
this.bottom = this.bottom + 10;

setTimeout(() => {
this.$refs.my_scroller.resize();
this.$refs.my_scroller.finishInfinite();
})
}, 1500)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-scroller",
"version": "0.3.9",
"version": "0.4.0",
"description": "Vue component for smooth scrolling, pull to refresh & infinite loading.",
"main": "src/index.js",
"author": "wangdahoo <157195705@qq.com>",
Expand Down

0 comments on commit a4d8e79

Please sign in to comment.