-
-
Notifications
You must be signed in to change notification settings - Fork 677
Lightbox spinner: Show spinner in Lightbox when slow to load #2946
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
base: main
Are you sure you want to change the base?
Conversation
src/lightbox/Lightbox.js
Outdated
|
|
||
| type State = { | ||
| movement: 'in' | 'out', | ||
| loaded: 0 | 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you choose 0 and 1 instead of boolean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I want to set flex value for PhotoView according to the current state(0 or 1), so that spinner can be displayed at center.
src/lightbox/Lightbox.js
Outdated
| }); | ||
|
|
||
| showImage = () => { | ||
| this.setState(({ loaded }, props) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to use this form of setState if you are not going to use the previous value of the state.
|
There is a I was considering a better option to a simple loading indicator to be to show the thumbnail stretched so we get a 'progressive loading' effect. |
jainkuniya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AdityaHirapara for the PR!
I would also suggest you to use loadingIndicatorSource. This till save manual styling (which is hard to maintain as there are high chances of breaking styles on different platforms with a small change) and showing loader by toggling var in state.
Thanks again!
|
@borisyankov @jainkuniya, Actually, loadingIndicatorSource is only to show any default image as a placeholder, I can't show any component like loadingSpinner there using this property. |
|
Thanks @AdityaHirapara for sending this! The screencap looks good -- doing something with a thumbnail / a low-res version would be still better, but this is a solid improvement over what we have. I agree with the code comments above. Would you send an updated version with those changes? One more comment on the code: the For example, how about |
Previously, Lightbox remains black until an image is loaded from the server. Spinner will be shown to user in Lightbox, while an image is being loaded. New state 'loaded' is defined in Lightbox component. When an image is loaded, the state will be changed from false to true and display value of 'PhotoView' also will be changed from 'none' to 'flex'. Fixes zulip#2896.
3a5470d to
20ed076
Compare
@gnprice I have made those changes. Also, now controlling 'PhotoView' with display instead of flex as suggested. Please review the changes. |
|
Thanks @AdityaHirapara for the PR and the fast reply! Sorry this reply of mine is much less fast. :-) There's just one thing I'm puzzled about when rereading this code: Do we really want to drop the If we do want this change, it seems like it can be understood separately from the rest of the changes, and so should be a separate commit. And in any case we'd definitely want to mention in the commit message that this change is happening and say why. I'm guessing the reason it's there is that in a previous version of the PR where we used
So I think probably if we just drop that line from the diff (i.e. keep that line unchanged in the code), this change will be good. The work needed to merge this is just to rebase, drop that line, and then retest that the code works as intended. |
Previously, Lightbox remains black until an image is loaded from the server. Spinner will be shown to user in Lightbox, while an image is being loaded.
Fixes #2896.