Skip to content

Commit

Permalink
0.0.16
Browse files Browse the repository at this point in the history
  • Loading branch information
lhlyu committed Dec 10, 2023
1 parent 095f60e commit 2cfccc1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- Local Import

```ts
import { VirtualWaterfall } from '@lhlyu/vue-virtual-waterfall'
import {VirtualWaterfall} from '@lhlyu/vue-virtual-waterfall'
```

- Global Import
Expand Down Expand Up @@ -48,6 +48,7 @@ app.use(VueVirtualWaterfall)

| Field | Type | Default Value | Description |
|--------------------|--------------------------------------------|-----------------------------------------|-------------------------------------------------|
| virtual | boolean | true | Enable virtual list |
| height | string | '100vh' | Container height |
| rowKey | string | 'id' | Key used for v-for loop |
| gap | number | 15 | Gap between each item |
Expand Down
1 change: 1 addition & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ app.use(VueVirtualWaterfall)

| 字段 | 类型 | 默认值 | 说明 |
|--------------------|--------------------------------------------|-----------------------------------------|-----------------|
| virtual | boolean | true | 是否启用虚拟列表 |
| height | string | '100vh' | 容器的高度 |
| rowKey | string | 'id' | v-for需要用到key |
| gap | number | 15 | 每个item之间的间隔 |
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@lhlyu/vue-virtual-waterfall",
"description": "vue3 virtual waterfall component",
"version": "0.0.15",
"version": "0.0.16",
"author": "lhlyu",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,32 +33,32 @@
"package.json"
],
"dependencies": {
"@vueuse/core": "^10.6.1"
"@vueuse/core": "^10.7.0"
},
"devDependencies": {
"@opentiny/vue-button": "^3.11.0",
"@opentiny/vue-form": "^3.11.1",
"@opentiny/vue-form-item": "^3.11.0",
"@opentiny/vue-icon": "^3.11.0",
"@opentiny/vue-numeric": "^3.11.0",
"@opentiny/vue-split": "^3.11.0",
"@opentiny/vue-switch": "^3.11.0",
"@opentiny/vue-button": "^3.12.0",
"@opentiny/vue-form": "^3.12.0",
"@opentiny/vue-form-item": "^3.12.0",
"@opentiny/vue-icon": "^3.12.0",
"@opentiny/vue-numeric": "^3.12.0",
"@opentiny/vue-split": "^3.12.0",
"@opentiny/vue-switch": "^3.12.0",
"@types/mockjs": "^1.0.10",
"@types/node": "^20.9.4",
"@vitejs/plugin-vue": "^4.5.0",
"@types/node": "^20.10.4",
"@vitejs/plugin-vue": "^4.5.2",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"autoprefixer": "^10.4.16",
"cssnano": "^6.0.1",
"mockjs": "^1.1.0",
"postcss": "^8.4.31",
"postcss": "^8.4.32",
"prettier": "^3.1.0",
"prettier-plugin-rational-order": "^1.0.3",
"sass": "^1.69.5",
"typescript": "^5.3.2",
"vite": "^5.0.2",
"typescript": "^5.3.3",
"vite": "^5.0.7",
"vite-plugin-css-injected-by-js": "^3.3.0",
"vite-plugin-dts": "^3.6.3",
"vue": "^3.3.8",
"vue-tsc": "^1.8.22"
"vite-plugin-dts": "^3.6.4",
"vue": "^3.3.11",
"vue-tsc": "^1.8.25"
}
}
4 changes: 4 additions & 0 deletions src/example/Example.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<template #left>
<VirtualWaterfall
ref="vm"
:virtual="waterfallOption.virtual"
:loading="waterfallOption.loading"
:gap="waterfallOption.gap"
:bottom-distance="waterfallOption.bottomDistance"
Expand Down Expand Up @@ -38,6 +39,9 @@
<TinyFormItem label="仅展示图片">
<TinySwitch v-model="waterfallOption.onlyImage"></TinySwitch>
</TinyFormItem>
<TinyFormItem label="虚拟列表">
<TinySwitch v-model="waterfallOption.virtual"></TinySwitch>
</TinyFormItem>
<TinyFormItem label="数据统计">
<p>当前页码: {{ data.page }} / {{ data.max }}</p>
<p>已加载量: {{ data.list.length }} / {{ data.total }}</p>
Expand Down
1 change: 1 addition & 0 deletions src/example/useWaterfall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const useWaterfall = () => {
// 瀑布流的一些属性
const waterfallOption = reactive({
loading: false,
virtual: true,
gap: 15,
bottomDistance: 250,
itemMinWidth: 250,
Expand Down
6 changes: 6 additions & 0 deletions src/vue-virtual-waterfall/virtual-waterfall.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ defineOptions({
})
interface VirtualWaterfallOption {
// 是否启用虚拟列表
virtual?: boolean
// 容器的高度
height?: string
rowKey?: string
Expand All @@ -64,6 +66,7 @@ interface VirtualWaterfallOption {
}
const props = withDefaults(defineProps<VirtualWaterfallOption>(), {
virtual: true,
height: '100vh',
rowKey: 'id',
gap: 15,
Expand Down Expand Up @@ -209,6 +212,9 @@ const itemRenderList = computed<SpaceOption[]>(() => {
if (!length) {
return []
}
if (!props.virtual) {
return itemSpaces.value
}
const top = -contentTop.value
const preloadScreenCount = props.preloadScreenCount
// 避免多次访问
Expand Down

0 comments on commit 2cfccc1

Please sign in to comment.