Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed Oct 27, 2024
1 parent 24810be commit fffff35
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/svelte/Virtualizer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,13 @@
return newItems;
});
const containerStyle = styleToString({
// contain: "content",
"overflow-anchor": "none", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer
flex: "none", // flex style can break layout
position: "relative",
visibility: "hidden", // TODO replace with other optimization methods
});
let dynamicContainerStyle = $derived(
let containerStyle = $derived(
styleToString({
// contain: "content",
"overflow-anchor": "none", // opt out browser's scroll anchoring because it will conflict to scroll anchoring of virtualizer
flex: "none", // flex style can break layout
position: "relative",
visibility: "hidden", // TODO replace with other optimization methods
width: horizontal ? totalSize + "px" : "100%",
height: horizontal ? "100%" : totalSize + "px",
"pointer-events": scrollDirection !== SCROLL_IDLE ? "none" : undefined,
Expand All @@ -171,11 +168,7 @@
@component
Customizable list virtualizer for advanced usage. See {@link VirtualizerProps} and {@link VirtualizerHandle}.
-->
<svelte:element
this={as}
bind:this={containerRef}
style={`${containerStyle} ${dynamicContainerStyle}`}
>
<svelte:element this={as} bind:this={containerRef} style={containerStyle}>
{#each items as item, i (getKey(item, i + extendedRange[0]))}
{@const index = i + extendedRange[0]}
<ListItem
Expand Down

0 comments on commit fffff35

Please sign in to comment.