-
Notifications
You must be signed in to change notification settings - Fork 113
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
You need to detect window resize events #1
Comments
Thanks, @istarkov I will publish to bower asap so it is possible to create Codepen and easily reproduce issues. Meanwhile if you can make an example or at least attach a gif (I recommend LiceCAP: http://www.cockos.com/licecap/) that would be awesome! Though I have some doubts for now:
|
|
I can be mistaken, obviously, so would really appreciate reproducible example! |
:-) |
I guess the solution could be - expose At the moment if content is always static with known height, I still do recalc, which is not optimal and can be easily fixed (keeping the same neat API)
|
Created #2 By the way, I do appreciate your input, it is invaluable |
Just to clarify. When animation is completed, container height is set to auto, so it is not locked. This means if you resize window neither content nor wrapper is fixed so content is not cut off. I guess that if you close amd open it again, height will stay previous, so animation will work till that initial height and then it will be expanded quickly to the actual height. Not a perfect effect but not extremely critical too, since all content will be visible. Thanks again for your comments. |
I understand you. But about not critical. For me this is also a strange user behavior when she load page, play with controls, resize page, play with controls again etc. |
I've added another button for my example to change some stub text inside container. So it became possible to resize window and therefore resize element. As I expected there is nothing bad happening with content and animation. The very little issue is there though, it was hard to spot, but I found it:
When container starts closing animation it starts it from the old height, so there is a tiny little flicker at the beginning of animation, but rest goes smoothly. I'll have a look how to fix it without window resize checks (don't really want to listen to window resize event). |
@nkbt it's very probable to have a window resize during animation on mobile, when the device is rotated. Slow your example animation down and you'll have plenty of time to simulate this on desktop. |
@nkbt also have a look at handling element resize as a browser-generated event: http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/ |
@sompylasar thank you very much, I will definitely address this issue. At the moment it may make animation imperfect, though it is still not critical, since all the content has In terms of perf, do you think it makes sense to expose something like |
@sompylasar thanks 👌 |
I'd be willing to do a PR for this if you want. Did it with react-measure and it works well https://github.com/souporserious/react-measure/blob/master/src/Resize-Handler.js just add everything to one handler. |
These are the reasons this issue is still open. At the moment I am leaning towards "wontfix" and explain in README (Gotchas section) how this can be "fixed" (if needed) on app level. Or someone (me?) can make a wrapper component for Collapse, that uses Collapse, listens to window resize and updates props for Collapse so it is re-measured. |
Hmm then maybe expose a public method to calc height? Then someone can handle resize if they want to on their own. I had done that with React Measure in the early stages. |
You can use Unless you meant to make Collapse recalc height (by internal means). In this case (at a workaround) you can toggle isOpened quickly like |
And recalculate height or set dirty flag on window resize.
Also there must be some kind of
refresh
method for situations like next:First component rendering occurs inside element with
display:none
stylea lot of tab controls use
display:none
styleHeight is always be zero inside such elements.
So without some kind of manual refresh it will be impossible to use this component.
Good Work!!! I like this.
The text was updated successfully, but these errors were encountered: