Closed basicBrogrammer closed 7 years ago
@basicBrogrammer you are right, there isn't anything in documentation about it.
Before I add CSS to render_async
, you can try out this solution if it fits you:
If you want to have a working spinner you can add CSS to your application:
/*
* Usage:
*
* <div class="sk-spinner sk-spinner-double-bounce">
* <div class="sk-double-bounce1"></div>
* <div class="sk-double-bounce2"></div>
* </div>
*
*/
.sk-spinner-double-bounce.sk-spinner {
width: 40px;
height: 40px;
position: relative;
margin: 0 auto;
}
.sk-spinner-double-bounce .sk-double-bounce1,
.sk-spinner-double-bounce .sk-double-bounce2 {
width: 100%;
height: 100%;
border-radius: 50%;
background-color: #8BB634;
opacity: 0.6;
position: absolute;
top: 0;
left: 0;
-webkit-animation: sk-doubleBounce 2s infinite ease-in-out;
animation: sk-doubleBounce 2s infinite ease-in-out;
}
.sk-spinner-double-bounce .sk-double-bounce2 {
-webkit-animation-delay: -1s;
animation-delay: -1s;
}
@-webkit-keyframes sk-doubleBounce {
0%,
100% {
-webkit-transform: scale(0);
transform: scale(0);
}
50% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
@keyframes sk-doubleBounce {
0%,
100% {
-webkit-transform: scale(0);
transform: scale(0);
}
50% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
In case anybody finds it useful, I am using this spinner, saved in app/assets/images/spinner/gif
:
with this in a .scss file:
.sk-spinner-double-bounce.sk-spinner {
background-image: image_url("spinner.gif");
background-size: contain;
display: inline-block;
width: 15px;
height: 15px;
}
This is makes pretty tiny spinners, as I am just loading numbers into a table asynchronously. Works great. Thanks for a really useful gem @nikolalsvk!
Thanks y'all
Didn't realize you were going to work on adding this... I was about to take the css from https://github.com/tobiasahlin/SpinKit and it worked after modifying it a little. I was doing this as a spike so I've deleted that branch already :/
One reason I abandoned the spike was bc one of my partials was a paginated collection. When i clicked to the next page it replaced my entire body with the async partial. Has anyone worked with this already?
Hey would y'all be interested in a PR to allow any of the spinkit spinners with a local variable passed to the render_async helper?
@basicBrogrammer sure thing, bring it on :)
You can use similar PR as an inspiration for it.
I've made some changes that lets you pass in your own placeholder. 💪
I've removed the old code that has CSS classes sk-spinner sk-spinner-bounce
.
You can checkout how to use your own placeholder in the README
It's not documented how this works and I'm not seeing the spinner on my page. How do you import the css for
sk-spinner sk-spinner-bounce
?