frinyvonnick / react-simple-infinite-loading

A list that infinitely loads content as user scrolls down in React
https://www.npmjs.com/package/react-simple-infinite-loading
Apache License 2.0
59 stars 13 forks source link

Add the possibility to customize the scrollbar #6

Closed frinyvonnick closed 4 years ago

frinyvonnick commented 5 years ago

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 👍

eduaugustus commented 5 years ago

Hi, can I do this?

frinyvonnick commented 5 years ago

Hi @eduaugustus 👋 thank you for considering contributing to this project! Sure feel free to open a pull request 👍

frinyvonnick commented 5 years ago

Hi @eduaugustus, do you need help on this ?

eduaugustus commented 5 years ago

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

frinyvonnick commented 5 years ago

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 😉

eduaugustus commented 5 years ago

ah okay, I'll use this :D

eduaugustus commented 5 years ago

@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?

frinyvonnick commented 5 years ago

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?

eduaugustus commented 5 years ago

@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

eduaugustus commented 5 years ago

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

frinyvonnick commented 5 years ago

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