Skip to content

Commit 0323262

Browse files
author
huangshuwei
committed
v1.1.0
1 parent 9bff927 commit 0323262

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

Diff for: README-CN.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
vue 懒加载容器,通过监听元素在页面中的可见性,决定是否加载资源并渲染。
1010

1111
## 解决什么问题
12+
1213
当页面内容超过一屏时,我们往往希望只加载并渲染当前一屏的数据,而随着页面的滚动,再去加载并渲染下面的内容。这样的好处可以大大提升页面打开速度,以及减少额外的网络请求(xhr)。vue-lazy-container 正好可以帮我们解决这个问题。
1314

1415
## Online Demo
@@ -40,7 +41,7 @@ Vue.use(VueLazyContainer);
4041

4142
```javascript
4243
<template>
43-
<vue-lazy-container tag-name="div" @change="visibilityChange">
44+
<vue-lazy-container tag-name="div" id=1 @change="visibilityChange">
4445
<template v-if="isLoaded">
4546
<!-- your content -->
4647
</template>
@@ -56,7 +57,7 @@ export default {
5657
},
5758
methods: {
5859
// visibility change
59-
visibilityChange(entry, observer) {
60+
visibilityChange(entry, observer, id) {
6061
const { isIntersecting } = entry;
6162

6263
// visibility
@@ -75,17 +76,17 @@ export default {
7576

7677
**Props**
7778

78-
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
79-
| ------- | ------------ | ----------------- | ---------------------------- | ------ |
80-
| tagName | 容器节点类型 | `Element.tagName` | div、span、p、img、i、a etc. | - |
81-
| intersectionOption | Intersection Observer Option | `Object` | root、rootMargin、threshold | - |
82-
79+
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
80+
| ------------------ | ---------------------------- | ----------------- | ---------------------------- | ------ |
81+
| tagName | 容器节点类型 | `Element.tagName` | div、span、p、img、i、a etc. | - |
82+
| id | 容器的 id | `String, Number` | - | - |
83+
| intersectionOption | Intersection Observer Option | `Object` | root、rootMargin、threshold | - |
8384

8485
**Event**
8586

86-
| 事件名称 | 说明 | 回调参数 |
87-
| -------- | ------------ | ---------- |
88-
| change | 元素可见变化事件 | [IntersectionObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)、observer |
87+
| 事件名称 | 说明 | 回调参数 |
88+
| -------- | ---------------- | ----------------------------------------------------------------------------------------------------------------- |
89+
| change | 元素可见变化事件 | [IntersectionObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)、observer、id|
8990

9091
## License
9192

Diff for: README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Example:
4040

4141
```javascript
4242
<template>
43-
<vue-lazy-container tag-name="div" @change="visibilityChange">
43+
<vue-lazy-container tag-name="div" id=1 @change="visibilityChange">
4444
<template v-if="isLoaded">
4545
<!-- your content -->
4646
</template>
@@ -56,7 +56,7 @@ export default {
5656
},
5757
methods: {
5858
// visibility change
59-
visibilityChange(entry, observer) {
59+
visibilityChange(entry, observer, id) {
6060
const { isIntersecting } = entry;
6161

6262
// visibility
@@ -78,14 +78,15 @@ export default {
7878
| Prop | Description | Type | Optional value | Default |
7979
| ------- | ------------ | ----------------- | ---------------------------- | ------ |
8080
| tagName | Element TagName | `Element.tagName` | div、span、p、img、i、a etc. | - |
81+
| id | container id | `String, Number` | - | - |
8182
| intersectionOption | Intersection Observer Option | `Object` | root、rootMargin、threshold | - |
8283

8384

8485
**Event**
8586

8687
| Event Name | Description | Callback Parameters |
8788
| -------- | ------------ | ---------- |
88-
| change | Element visible change events | [IntersectionObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)、observer |
89+
| change | Element visible change events | [IntersectionObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)、observer、id |
8990

9091
## License
9192

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-lazy-container",
3-
"version": "1.1.0-beta.2",
3+
"version": "1.1.0",
44
"description": "listening to the visibility of elements in the page",
55
"keywords": [
66
"vue",

0 commit comments

Comments
 (0)