[new feature] add sticky component (#3888)

This commit is contained in:
neverland
2019-07-18 17:48:18 +08:00
committed by GitHub
parent e1021e70ba
commit b273c89b3a
23 changed files with 651 additions and 124 deletions
+66
View File
@@ -0,0 +1,66 @@
# Sticky
### Install
``` javascript
import { Sticky } from 'vant';
Vue.use(Sticky);
```
## Usage
### Basic Usage
```html
<van-sticky>
<van-button type="primary">Basic Usage</van-button>
</van-sticky>
```
### Offset Top
```html
<van-sticky :offset-top="50">
<van-button type="info">Offset Top</van-button>
</van-sticky>
```
### Set Container
```html
<div ref="container" style="height: 150px;">
<van-sticky :container="container">
<van-button type="warning">Set Container</van-button>
</van-sticky>
</div>
```
```js
export default {
data() {
return {
container: null
};
},
mounted() {
this.container = this.$refs.container;
}
};
```
## API
### Props
| Attribute | Description | Type | Default |
|------|------|------|------|
| offset-top | Offset top | `number` | `0` | - |
| z-index | z-index when sticky | `number` | `99` | - |
| container | Container DOM | `HTMLElement` | - | - |
### Events
| Event | Description | Arguments |
|------|------|------|
| scroll | Triggered when scroll | object: { scrollTop, isFixed } |