smooth-scrollbar-react icon indicating copy to clipboard operation
smooth-scrollbar-react copied to clipboard

How to have smooth scroll on full website

Open tahonaPL opened this issue 3 years ago • 2 comments

Hi, I'm trying to have full body scroll. How to achieve this without fixed height ?

function App() {
  return (
     <Scrollbar
          plugins={{
            overscroll: {
              effect: 'glow',
            },
          }}>
    <div className='App'>
      <div className='list-data' style={{}}>
          {[...Array(20).keys()].map((value, index) => (
            <div key={index}>{value + index}</div>
          ))}
       
      </div>
    </div>
 </Scrollbar>
  );
}```

tahonaPL avatar Dec 16 '21 12:12 tahonaPL

@tahonaPL To body scroll without fixed height, you can use position: fixed and height: 100vh instead.

nghiepdev avatar Dec 19 '21 07:12 nghiepdev

I added width: 100vw to position: fixed and height: 100vh and it works perfectly 🥳

function App() {
  return (
    <div
      className="App"
      style={{
        display: "flex",
        flexDirection: "column",
        position: "fixed",
        height: "100vh",
        width: "100vw",
      }}
    >
      <Scrollbar
        plugins={{
          overscroll: {
            effect: "glow",
          } as const,
        }}
      >
        <div>
          {[...Array(300).fill(0)].map((value, index) => (
            <div key={index}>{value + index}</div>
          ))}
        </div>
      </Scrollbar>
    </div>
  );
}

gutovskii avatar Jul 27 '23 15:07 gutovskii