Skip to content

Commit

Permalink
fix: cleaning dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
orefalo committed Oct 22, 2024
1 parent 9586d3f commit 40d73f5
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 171 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@
"@commitlint/config-conventional": "^19.5.0",
"@playwright/test": "^1.48.1",
"@sveltejs/adapter-static": "^3.0.5",
"@sveltejs/kit": "^2.7.1",
"@sveltejs/package": "^2.3.5",
"@sveltejs/kit": "^2.7.2",
"@sveltejs/package": "^2.3.6",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@types/eslint": "^9.6.1",
"@types/node": "^22.7.7",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"@types/node": "^22.7.8",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"badge-maker": "^4.1.0",
"copyfiles": "^2.4.1",
"clsx": "^2.1.1",
Expand All @@ -75,7 +75,7 @@
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-gitignore": "^0.1.0",
"eslint-plugin-svelte": "^2.45.1",
"eslint-plugin-svelte": "^2.46.0",
"globals": "^15.11.0",
"highlight.js": "^11.10.0",
"husky": "^9.1.6",
Expand All @@ -90,10 +90,10 @@
"svelte-preprocess": "^6.0.3",
"tslib": "^2.8.0",
"typescript": "^5.6.3",
"typescript-eslint": "^8.10.0",
"typescript-eslint": "^8.11.0",
"vite": "^5.4.9"
},
"peerDependencies": {
"svelte": "^5.0.0"
"svelte": "^5.0.5"
}
}
279 changes: 136 additions & 143 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/app.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

body {
font-family: Helvetica, Arial, sans-serif;
color: rgba(116, 103, 103);
Expand Down
29 changes: 13 additions & 16 deletions src/lib/VirtualListNew.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,14 @@
// Holds the calculated size (height or width) of each item in the list
const sizes: number[] = $derived.by(() => {
return items.map((item, index) => {
const r = items.map((item, index) => {
let s = sizingCalculator?.(index, item);
if (s !== undefined) return s;
s = rawSizes[index];
if (s !== undefined) return s;
return avgSizeInPx;
});
return r;
});
// this is index -> viewport offset
Expand Down Expand Up @@ -268,17 +269,11 @@
});
$effect(() => {
const { offset, scrollChangeReason } = curState;
if (prevState?.offset !== offset || prevState?.scrollChangeReason !== scrollChangeReason) {
if (curState.scrollChangeReason === SCROLL_CHANGE_REASON.REQUESTED) {
scrollTo(curState.offset);
} else {
refreshOffsets();
}
if (prevState?.offset !== offset && scrollChangeReason === SCROLL_CHANGE_REASON.REQUESTED) {
scrollTo(offset);
}
prevState = curState;
});
let prevProps: VProps = {};
Expand Down Expand Up @@ -350,15 +345,17 @@
function onScroll(event: Event): void {
const offset = isHorizontal ? listContainer.scrollLeft : listContainer.scrollTop;
if (event.target !== listContainer || offset < 0 || curState.offset === offset) return;
curState = {
offset,
scrollChangeReason: SCROLL_CHANGE_REASON.OBSERVED
};
if (prevState?.offset !== offset) {
console.log(sizes);
curState = {
offset,
scrollChangeReason: SCROLL_CHANGE_REASON.OBSERVED
};
onAfterScroll?.({ offset, event });
onAfterScroll?.({ offset, event });
}
}
function getOffsetForIndex(
Expand Down
1 change: 0 additions & 1 deletion src/routes/examples/events/+page.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/routes/examples/positioning/+page.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/routes/examples/vertical/code.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<VirtualList items={myModel} style="height:600px">
{#snippet vl_slot({ index, item }: VLSlotSignature<(typeof myModel)[0]>)}

Check warning on line 11 in src/routes/examples/vertical/code.svelte

View workflow job for this annotation

GitHub Actions / tests

'index' is defined but never used. Allowed unused args must match /^_/u
<div style="border: 1px solid rgb(204, 204, 204)">
<img src="https://picsum.photos/id/{index % 1000}/100/100.webp" alt="nono" />
{item.text}
</div>
{/snippet}
Expand Down
17 changes: 17 additions & 0 deletions src/routes/examples/vertical/codeImg.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script lang="ts">
import { VirtualList, type VLSlotSignature } from 'svelte-virtuallists';
import { getRandomSushi } from '../sushi';
const myModel = new Array(10000).fill(1).map((v, i) => {
return { text: '#' + i + ' ' + getRandomSushi() };
});
</script>

<VirtualList items={myModel} style="height:600px">
{#snippet vl_slot({ index, item }: VLSlotSignature<(typeof myModel)[0]>)}
<div style="border: 1px solid rgb(204, 204, 204)">
<img src="https://picsum.photos/id/{index % 1000}/100/100.webp" alt="nono" />
{item.text}
</div>
{/snippet}
</VirtualList>

0 comments on commit 40d73f5

Please sign in to comment.