@wyxos/vibe 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +188 -139
- package/lib/demo.webp +0 -0
- package/lib/index.js +518 -423
- package/lib/vibe.css +1 -1
- package/package.json +1 -1
- package/src/App.vue +124 -23
- package/src/Masonry.vue +17 -7
- package/src/components/MasonryItem.vue +132 -0
- package/src/style.css +30 -0
package/README.md
CHANGED
|
@@ -1,139 +1,188 @@
|
|
|
1
|
-
# VIBE — Vue Infinite Block Engine
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@wyxos/vibe)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://wyxos.github.io/vibe/)
|
|
6
|
-
|
|
7
|
-
A high-performance, responsive masonry layout engine for Vue 3 with built-in infinite scrolling and virtualization.
|
|
8
|
-
|
|
9
|
-
VIBE (Vue Infinite Block Engine) is designed for applications that need to display large datasets in a masonry grid without compromising performance. Unlike other masonry libraries, VIBE leverages virtualization to render only what is visible on the screen, ensuring smooth scrolling even with thousands of items.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
:
|
|
61
|
-
:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
1
|
+
# VIBE — Vue Infinite Block Engine
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@wyxos/vibe)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://wyxos.github.io/vibe/)
|
|
6
|
+
|
|
7
|
+
A high-performance, responsive masonry layout engine for Vue 3 with built-in infinite scrolling and virtualization.
|
|
8
|
+
|
|
9
|
+
VIBE (Vue Infinite Block Engine) is designed for applications that need to display large datasets in a masonry grid without compromising performance. Unlike other masonry libraries, VIBE leverages virtualization to render only what is visible on the screen, ensuring smooth scrolling even with thousands of items.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **High Performance Virtualization**: Efficiently renders thousands of items by only mounting elements currently in the viewport.
|
|
18
|
+
- **Responsive Masonry Layout**: Automatically adjusts column counts and layout based on screen width and breakpoints.
|
|
19
|
+
- **Infinite Scrolling**: Seamlessly loads more content as the user scrolls, with built-in support for async data fetching.
|
|
20
|
+
- **Dynamic Updates**: Supports adding, removing, and reflowing items with smooth FLIP animations.
|
|
21
|
+
- **Scroll Position Maintenance**: Keeps the user's scroll position stable when new items are loaded or the layout changes.
|
|
22
|
+
- **Built-in Item Component**: Includes a production-ready `MasonryItem` with image preloading, error handling, and hover effects.
|
|
23
|
+
- **Customizable Rendering**: Full control over item markup via scoped slots.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @wyxos/vibe
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### Basic Usage (Default Item)
|
|
38
|
+
|
|
39
|
+
By default, VIBE uses the built-in `MasonryItem` component, which handles image loading and provides a clean UI.
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<script setup>
|
|
43
|
+
import { ref } from 'vue'
|
|
44
|
+
import { Masonry } from '@wyxos/vibe'
|
|
45
|
+
|
|
46
|
+
const items = ref([])
|
|
47
|
+
|
|
48
|
+
// Layout configuration
|
|
49
|
+
const layout = {
|
|
50
|
+
gutterX: 12,
|
|
51
|
+
gutterY: 12,
|
|
52
|
+
sizes: { base: 1, sm: 2, md: 3, lg: 4 }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function getNextPage(page) {
|
|
56
|
+
const response = await fetch(`/api/items?page=${page}`)
|
|
57
|
+
const data = await response.json()
|
|
58
|
+
// Items must have a 'src' property for the default MasonryItem
|
|
59
|
+
return {
|
|
60
|
+
items: data.items,
|
|
61
|
+
nextPage: page + 1
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<Masonry
|
|
68
|
+
v-model:items="items"
|
|
69
|
+
:get-next-page="getNextPage"
|
|
70
|
+
:layout="layout"
|
|
71
|
+
/>
|
|
72
|
+
</template>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Custom Item Rendering
|
|
76
|
+
|
|
77
|
+
You can fully customize the item rendering using the `#item` slot. You can also import and use `MasonryItem` inside the slot if you want to wrap it or extend it.
|
|
78
|
+
|
|
79
|
+
```vue
|
|
80
|
+
<script setup>
|
|
81
|
+
import { Masonry, MasonryItem } from '@wyxos/vibe'
|
|
82
|
+
// ... setup code ...
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<template>
|
|
86
|
+
<Masonry
|
|
87
|
+
v-model:items="items"
|
|
88
|
+
:get-next-page="getNextPage"
|
|
89
|
+
:layout="layout"
|
|
90
|
+
>
|
|
91
|
+
<template #item="{ item, remove }">
|
|
92
|
+
<!-- Custom container -->
|
|
93
|
+
<div class="custom-card">
|
|
94
|
+
<!-- You can use the built-in item or your own -->
|
|
95
|
+
<MasonryItem :item="item" :remove="remove">
|
|
96
|
+
<!-- Optional: MasonryItem also has a default slot for overlays -->
|
|
97
|
+
<div class="absolute bottom-0 p-2 text-white">
|
|
98
|
+
{{ item.title }}
|
|
99
|
+
</div>
|
|
100
|
+
</MasonryItem>
|
|
101
|
+
</div>
|
|
102
|
+
</template>
|
|
103
|
+
</Masonry>
|
|
104
|
+
</template>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Props
|
|
110
|
+
|
|
111
|
+
| Prop | Type | Required | Description |
|
|
112
|
+
|------|------|----------|-------------|
|
|
113
|
+
| `items` | `Array` | Yes | Two-way bound item array. Each item must include `width`, `height`, and `id`. |
|
|
114
|
+
| `getNextPage` | `Function(page: Number)` | Yes | Async function to load the next page. Must return `{ items, nextPage }`. |
|
|
115
|
+
| `layout` | `Object` | No | Configuration object for layout, including sizes and gutters. |
|
|
116
|
+
| `loadAtPage` | `Number` | No | The starting page number (default: `1`). |
|
|
117
|
+
| `paginationType` | `String` | No | `'page'` or `'cursor'` (default: `'page'`). |
|
|
118
|
+
| `pageSize` | `Number` | No | Number of items per page, used for backfilling (default: `40`). |
|
|
119
|
+
|
|
120
|
+
### Layout Configuration Example
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
{
|
|
124
|
+
gutterX: 10,
|
|
125
|
+
gutterY: 10,
|
|
126
|
+
sizes: {
|
|
127
|
+
base: 1,
|
|
128
|
+
sm: 2,
|
|
129
|
+
md: 3,
|
|
130
|
+
lg: 4,
|
|
131
|
+
xl: 5,
|
|
132
|
+
'2xl': 6
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## MasonryItem Component
|
|
140
|
+
|
|
141
|
+
The built-in `MasonryItem` component is available for use within the `#item` slot or as a standalone component.
|
|
142
|
+
|
|
143
|
+
### Props
|
|
144
|
+
|
|
145
|
+
| Prop | Type | Description |
|
|
146
|
+
|------|------|-------------|
|
|
147
|
+
| `item` | `Object` | The item object. Must contain `src` for image loading. |
|
|
148
|
+
| `remove` | `Function` | Optional callback to remove the item. If provided, a remove button is shown. |
|
|
149
|
+
|
|
150
|
+
### Features
|
|
151
|
+
- **Image Preloading**: Shows a spinner while the image loads.
|
|
152
|
+
- **Error Handling**: Displays an error state if the image fails to load.
|
|
153
|
+
- **Hover Effects**: Includes a subtle zoom and overlay on hover.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Slots
|
|
158
|
+
|
|
159
|
+
| Slot Name | Props | Description |
|
|
160
|
+
|-----------|-------|-------------|
|
|
161
|
+
| `item` | `{ item, remove }` | Scoped slot for custom rendering of each masonry block. |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Run Locally
|
|
166
|
+
|
|
167
|
+
To run the demo project locally:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
git clone https://github.com/wyxos/vibe
|
|
171
|
+
cd vibe
|
|
172
|
+
npm install
|
|
173
|
+
npm run dev
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Visit `http://localhost:5173` to view the demo.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Live Demo
|
|
181
|
+
|
|
182
|
+
[View Live Demo on GitHub Pages](https://wyxos.github.io/vibe/)
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
MIT © [@wyxos](https://github.com/wyxos)
|
package/lib/demo.webp
ADDED
|
Binary file
|