Skip to content

Does a horizontal list require the elements to be position absolute? #748

Answered by mt-deva
mt-deva asked this question in Q&A
Discussion options

You must be logged in to vote

Answered here

#476 (comment)

Created a working demo here
https://codesandbox.io/p/sandbox/horizontal-scroll-nsmfjd

import React from "react";
import "./styles.css";
import { useVirtualizer } from "@tanstack/react-virtual";

const columns = new Array(10000)
  .fill(true)
  .map(() => 75 + Math.round(Math.random() * 100));

export default function App() {
  return (
    <div>
      <h3>Columns</h3>
      <ColumnVirtualizer columns={columns} />
    </div>
  );
}

function ColumnVirtualizer({ columns }) {
  const parentRef = React.useRef();

  const columnVirtualizer = useVirtualizer({
    horizontal: true,
    count: columns.length,
    getScrollElement: () => parentRef.current,
    estimate…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mt-deva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant