frinyvonnick / react-simple-infinite-loading

A list that infinitely loads content as user scrolls down in React

Home Page:https://www.npmjs.com/package/react-simple-infinite-loading

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add the possibility to customize the scrollbar

frinyvonnick opened this issue Β· comments

It would be nice to have the possibility to customize the scrollbar. Here is an example.

There is a codesandbox with a working example of code πŸ‘

Hi, can I do this?

Hi @eduaugustus πŸ‘‹ thank you for considering contributing to this project! Sure feel free to open a pull request πŸ‘

Hi @eduaugustus, do you need help on this ?

Hi @frinyvonnick, I been thinkin about the solution, it's ok use react-custom-scrollbar?

You mean this repository https://github.com/malte-wessel/react-custom-scrollbars ? Sure it is the one used in the codesandox I linked as example πŸ˜‰

ah okay, I'll use this :D

@frinyvonnick I've been thinking about solution in this weekend. The dev go set a prop in scroolbar like customScroolbar and with this react render a custom default scroolbar or dev should pass custom custom config?

You mean something like this:

<InfiniteLoading
  hasMoreItems={hasMore}
  itemHeight={40}
  loadMoreItems={fetchMore}
+ scrollbar
>
  {items.map(item => <div key={item}>{item}</div>)}
</InfiniteLoading>

If scrollbar prop is set we use react-custom-scrollbars otherwise we keep native scrollbar. We can also add a scrollbarProps prop to pass down options to react-custom-scrollbars.

<InfiniteLoading
  hasMoreItems={hasMore}
  itemHeight={40}
  loadMoreItems={fetchMore}
+ scrollbar
+ scrollbarProps={{ universal: true }}
>
  {items.map(item => <div key={item}>{item}</div>)}
</InfiniteLoading>

Does it seems correct?

@frinyvonnick Hmm this style I think the scroll gonna have many props, I realy been think other way, if you pass customScrollbar prop, scrollbar has a condition render, if is true, render a default custom scrollbar, if false, render normal browser scroll

@frinyvonnick LOL I'm sorry, I not understand before, but now it's clear, what you say is right hahaha

πŸ‘‹ @eduaugustus If you want some help you could create a pull request with your implementation so we could discuss about it together?