Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose onResize hook in gemini-scrollbar #19

Merged
merged 3 commits into from
Mar 7, 2017

Conversation

richvdh
Copy link
Contributor

@richvdh richvdh commented Apr 17, 2016

This exposes the onResize hook added by noeldelgado/gemini-scrollbar#26.

@richvdh richvdh changed the title Expose onScroll hook in gemini-scrollbar Expose onResize hook in gemini-scrollbar Apr 17, 2016
@richvdh richvdh force-pushed the rav/expose_onscroll branch from b2502f6 to 6b06e90 Compare April 17, 2016 21:19
@noeldelgado
Copy link
Owner

Thanks for the pull request @richvdh. I am not sure if this approach will work for React components, since we will be creating nodes in componentDidMount (the new element) which goes against React rules. We may need to explicitly put the new element in the render method and make sure gemini doesn't try to create this element again.

Will do some tests and see how it goes. For now I updated this package to use gemini v1.3.x so the window.resize event is still attached.

@richvdh
Copy link
Contributor Author

richvdh commented May 31, 2016

In my testing, I found that trying to create the object element in render gave some very strange results, as I alluded to here.

Creating the new element in componentDidMount should be fine - once react has created the GeminiScrollbar, it doesn't need to look at the children of the DOM element. I wasn't able to find a reference to this being against the rules.

@richvdh
Copy link
Contributor Author

richvdh commented Jun 22, 2016

@noeldelgado: any feedback on this?

@noeldelgado
Copy link
Owner

@richvdh: sorry, I haven't had time, I will try to check it this week.

@noeldelgado
Copy link
Owner

Hi @richvdh, I just check it and found out a problem when the render method depends on state (setState...), the result is that React will re-render the whole thing losing the scroll position (scrolling up), I'm thinking about adding an extra option to tell gemini-scrollbar to do not dynamically add the resizer object (something like _addResizeObject: <Boolean[true]>) so React does not render the whole tree on every update, this option is suppose to be used by us specifically (kinda a private option) and not by other users. I will be working on this in the following days, if you want to see a working example of what I am referring to, let me know, I will try to publish it. Thank you so much for your contribution.

@richvdh
Copy link
Contributor Author

richvdh commented Jul 22, 2016

@noeldelgado: I'm not sure I follow you.

It's certainly true that setState will make React re-render (that's kinda the point). But that shouldn't make the browser lose the scroll position, because the DOM shouldn't change (much). Our application does a setState on parent components of the gemini-scrollbar all the time, without problems. Do you have a demonstration of the problem?

@noeldelgado
Copy link
Owner

Hi, @richvdh,

Sorry for the late response. I just tried this change once again and it works as expected, so I'll proceed to merge it.

Thanks.

@noeldelgado noeldelgado merged commit 54b5b2e into noeldelgado:master Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants