Skip to content

Commit c3929ef

Browse files
committed
Support item-class-add function
1 parent 9eaa126 commit c3929ef

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@ More usages or getting start you can refer to these clearly [examples](https://g
165165
<td></td>
166166
<td>Emited when scrolled to bottom or right, param <code>(event, range)</code>.</td>
167167
</tr>
168-
<tr>
169-
<td><code>resized</code></td>
170-
<td>Event</td>
171-
<td></td>
172-
<td>Emited when each item resized (mounted), param <code>(id, size)</code>.</td>
173-
</tr>
174168
</table>
175169
</details>
176170

@@ -196,6 +190,12 @@ More usages or getting start you can refer to these clearly [examples](https://g
196190
<td>0</td>
197191
<td>Setting scroll stay offset.</td>
198192
</tr>
193+
<tr>
194+
<td><code>resized</code></td>
195+
<td>Event</td>
196+
<td></td>
197+
<td>Emited when each item resized (mounted), param <code>(id, size)</code>.</td>
198+
</tr>
199199
<tr>
200200
<td><code>root-tag</code></td>
201201
<td>String</td>
@@ -226,6 +226,12 @@ More usages or getting start you can refer to these clearly [examples](https://g
226226
<td></td>
227227
<td>Item wrapper element class name.</td>
228228
</tr>
229+
<tr>
230+
<td><code>item-class-add</code></td>
231+
<td>Function</td>
232+
<td></td>
233+
<td>A function that you can return extra class (String) to item wrapper element, param <code>(index)</code>.</td>
234+
</tr>
229235
<tr>
230236
<td><code>header-tag</code></td>
231237
<td>String</td>
@@ -287,7 +293,7 @@ Here are some usefull public methods you can call via [`ref`](https://vuejs.org/
287293

288294
* `getSizes()`: get the total number of stored (rendered) items.
289295

290-
* `getClientSize()`: get wrapper client viewport size (width or height).
296+
* `getClientSize()`: get wrapper element client viewport size (width or height).
291297

292298
* `getScrollSize()`: get all scroll size (scrollHeight or scrollWidth).
293299

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ const VirtualList = Vue.component('virtual-list', {
227227
if (dataSource) {
228228
if (dataSource[dataKey]) {
229229
slots.push(h(Item, {
230-
class: itemClass,
231230
props: {
232231
index,
233232
tag: itemTag,
@@ -237,7 +236,8 @@ const VirtualList = Vue.component('virtual-list', {
237236
source: dataSource,
238237
extraProps: extraProps,
239238
component: dataComponent
240-
}
239+
},
240+
class: `${itemClass} ${this.itemClassAdd ? this.itemClassAdd(index) : ''}`
241241
}))
242242
} else {
243243
console.warn(`Cannot get the data-key '${dataKey}' from data-sources.`)

src/props.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export const VirtualProps = {
7070
type: String,
7171
default: ''
7272
},
73+
itemClassAdd: {
74+
type: Function
75+
},
7376

7477
headerTag: {
7578
type: String,

0 commit comments

Comments
 (0)