Skip to content

#43 scroll position #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
Ruben L committed Jun 2, 2021
commit b834e770d6b96062484b37416d1c2d4c5dcf59d3
22 changes: 0 additions & 22 deletions VirtualList.svelte
Original file line number Diff line number Diff line change
@@ -5,9 +5,6 @@
export let items;
export let height = '100%';
export let itemHeight = undefined;

let foo;

// read-only, but visible to consumers via bind:start
export let start = 0;
export let end = 0;
@@ -109,25 +106,6 @@
while (i < items.length) height_map[i++] = average_height;
bottom = remaining * average_height;

// prevent jumping if we scrolled up into unknown territory
return
if (start < old_start) {
await tick();

let expected_height = 0;
let actual_height = 0;

for (let i = start; i < old_start; i +=1) {
if (rows[i - start]) {
expected_height += height_map[i];
actual_height += itemHeight || rows[i - start].offsetHeight;
}
}

const d = actual_height - expected_height;
viewport.scrollTo(0, scrollTop + d);
}

// TODO if we overestimated the space these
// rows would occupy we may need to add some
// more. maybe we can just call handle_scroll again?