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

How to control the position of the loading bar? #70

Open
Issaminu opened this issue Oct 20, 2022 · 2 comments
Open

How to control the position of the loading bar? #70

Issaminu opened this issue Oct 20, 2022 · 2 comments

Comments

@Issaminu
Copy link

This seems like a great project; I do have a question, however.
The loading bar seems to always start at the top left of the page, regardless of placement of the LoadingBar inside the application. How to make the loading bar fit inside a card for example?
or in the case of an application using a vertical navigation bar, how could the loading bar start next to the navbar, rather than to always start from the top left of the page (meaning it would start on top of the navbar)?

@Issaminu
Copy link
Author

Ended up solving this myself, turns out the main reason was that there's a hidden container for the LoadingBar component, and it has this property: zIndex: 99999999999, see here.
So, to control the position of the LoadingBar, we just need to use the property containerStyle to pass attributes to the LoadingBar's container.
In the case of my vertical navigation bar, I set it's zIndex=999999 and then passed the following prop to LoadingBar:
containerStyle={{left: "7rem", zIndex: 1}}
This does work well on a big screen where the full navbar is present but doesn't work when the navbar changes to a pop-up (on a mobile screen), So, to control the containerStyle's attributes depending on screen size, I used the following snippet to generate a width state that changes with the change of window.innerWidth. Then I changed containerStyle accordingly:
containerStyle={width > 768 ? { left: "7rem", zIndex: 1 } : {} }
So now the LoadingBar's container will follow different rules according to viewport.

I'm not closing this issue since I believe this is a specific workaround for my particular use case. So this remains to be a problem, especially when it comes to changing the position of the LoadingBar to reside inside a specific div, like in a card containg a form.

@alpzaf
Copy link

alpzaf commented Feb 21, 2023

Ended up solving this myself, turns out the main reason was that there's a hidden container for the LoadingBar component, and it has this property: zIndex: 99999999999, see here. So, to control the position of the LoadingBar, we just need to use the property containerStyle to pass attributes to the LoadingBar's container. In the case of my vertical navigation bar, I set it's zIndex=999999 and then passed the following prop to LoadingBar: containerStyle={{left: "7rem", zIndex: 1}} This does work well on a big screen where the full navbar is present but doesn't work when the navbar changes to a pop-up (on a mobile screen), So, to control the containerStyle's attributes depending on screen size, I used the following snippet to generate a width state that changes with the change of window.innerWidth. Then I changed containerStyle accordingly: containerStyle={width > 768 ? { left: "7rem", zIndex: 1 } : {} } So now the LoadingBar's container will follow different rules according to viewport.

I'm not closing this issue since I believe this is a specific workaround for my particular use case. So this remains to be a problem, especially when it comes to changing the position of the LoadingBar to reside inside a specific div, like in a card containg a form.

<LoadingBar containerStyle={{position: 'absolute'}} /> just give position: absolute to containerStyle prop and position: relative to the parent element then you can place loadingBar into div or card etc.

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

No branches or pull requests

2 participants