Skip to content

Commit 23d2ac3

Browse files
committed
feat: enforce exclusivity between scrollToIndex and scrollToOffset #32
1 parent 00d2ae4 commit 23d2ac3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/lib/VirtualListNew.svelte

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@
7272
endIdx?: number;
7373
}
7474
75+
type VariantScrollToIndex = {
76+
scrollToIndex: number;
77+
scrollToOffset?: undefined;
78+
};
79+
80+
type VariantScrollToOffset = {
81+
scrollToIndex?: undefined;
82+
scrollToOffset: number;
83+
};
84+
7585
// ====== PROPERTIES ================
7686
7787
const {
@@ -115,9 +125,6 @@
115125
isHorizontal?: boolean;
116126
isTable?: boolean;
117127
118-
// positioning
119-
scrollToIndex?: number | undefined;
120-
scrollToOffset?: number | undefined;
121128
122129
// scroll attributes
123130
scrollToAlignment?: ALIGNMENT;
@@ -140,7 +147,7 @@
140147
style?: string;
141148
142149
sizingCalculator?: SizingCalculatorFn;
143-
} = $props();
150+
} & (VariantScrollToIndex | VariantScrollToOffset) = $props();
144151
145152
// ======== VARIABLES ========
146153

0 commit comments

Comments
 (0)