Skip to content

Commit 99e3b51

Browse files
author
Corentin Mors
committed
Let class infer generic type
1 parent 11ad882 commit 99e3b51

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-virtual-grid",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"author": "Corentin Mors <[email protected]>",
55
"license": "MIT",
66
"repository": "github:mikescops/vue-virtual-grid",

src/VirtualGrid.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ interface RenderData<P> {
4545
}
4646
4747
@Component
48-
export default class VirtualGrid extends Vue {
49-
@Prop({ default: () => (): Item<unknown>[] => [] }) updateFunction: <P>(params: { offset: number }) => Item<P>[];
48+
export default class VirtualGrid<P> extends Vue {
49+
@Prop({ default: () => (): Item<unknown>[] => [] }) updateFunction: (params: { offset: number }) => Item<P>[];
5050
@Prop({ default: () => getGridGapDefault }) getGridGap: (elementWidth: number, windowHeight: number) => number;
5151
@Prop({ default: () => getColumnCountDefault }) getColumnCount: (elementWidth: number) => number;
5252
@Prop({ default: () => getWindowMarginDefault }) getWindowMargin: (windowHeight: number) => number;
@@ -56,7 +56,7 @@ export default class VirtualGrid extends Vue {
5656
columnWidth: number
5757
) => number;
5858
59-
@ProvideReactive() items: Item<unknown>[] = [];
59+
@ProvideReactive() items: Item<P>[] = [];
6060
6161
@ProvideReactive() offset: number = 0;
6262
@ProvideReactive() bottomReached: boolean = false;
@@ -70,19 +70,19 @@ export default class VirtualGrid extends Vue {
7070
elementSize: { height: 0, width: 0 },
7171
};
7272
73-
@ProvideReactive() configData: ConfigData<unknown> = {
73+
@ProvideReactive() configData: ConfigData<P> = {
7474
windowMargin: 0,
7575
gridGap: 0,
7676
columnCount: 1,
7777
entries: [],
7878
};
7979
80-
@ProvideReactive() layoutData: LayoutData<unknown> = {
80+
@ProvideReactive() layoutData: LayoutData<P> = {
8181
totalHeight: 0,
8282
cells: [],
8383
};
8484
85-
@ProvideReactive() renderData: RenderData<unknown> = {
85+
@ProvideReactive() renderData: RenderData<P> = {
8686
cellsToRender: [],
8787
firstRenderedRowNumber: 0,
8888
firstRenderedRowOffset: 0,
@@ -154,7 +154,7 @@ export default class VirtualGrid extends Vue {
154154
this.containerData = { windowSize, windowScroll, elementWindowOffset, elementSize };
155155
}
156156
157-
computeConfigData<P>(containerData: ContainerData, items: Item<P>[]) {
157+
computeConfigData(containerData: ContainerData, items: Item<P>[]) {
158158
const elementWidth = containerData.elementSize ? containerData.elementSize.width : null;
159159
160160
const windowMargin = this.getWindowMargin(containerData.windowSize.height);
@@ -187,7 +187,7 @@ export default class VirtualGrid extends Vue {
187187
};
188188
}
189189
190-
computeLayoutData<P>(configData: ConfigData<P>) {
190+
computeLayoutData(configData: ConfigData<P>) {
191191
if (configData === null) {
192192
return;
193193
}
@@ -241,7 +241,7 @@ export default class VirtualGrid extends Vue {
241241
this.layoutData = { cells, totalHeight };
242242
}
243243
244-
computeRenderData<P>(configData: ConfigData<P>, containerData: ContainerData, layoutData: LayoutData<P>) {
244+
computeRenderData(configData: ConfigData<P>, containerData: ContainerData, layoutData: LayoutData<P>) {
245245
if (layoutData === null || configData === null) {
246246
return;
247247
}
@@ -299,7 +299,7 @@ export default class VirtualGrid extends Vue {
299299
return columnWidth;
300300
}
301301
302-
getGridRowStart<P>(cell: Cell<P>, renderData: RenderData<P> | null) {
302+
getGridRowStart(cell: Cell<P>, renderData: RenderData<P> | null) {
303303
if (renderData === null) {
304304
return undefined;
305305
}

0 commit comments

Comments
 (0)