Comments (16)
You can also do with pure javascript
(required IE10+ )
var spinner = new Spinner(opts).spin(target);
target.classList.add("opaque");
# Stop Spin
target.classList.remove("opaque");
spinner.stop()
https://developer.mozilla.org/en/docs/Web/API/Element/classList
from spin.js.
Which would do what?
from spin.js.
I though that there's a background div created for the spinner. So I imagined it would be possible to set the background and it's opacity.
But now I kind of see it's a bit tricky...
Sorry for the dumb "issue".
So do I have to wrap it in my own div and position to have the transparent background?
I hoped there's an easier way...
from spin.js.
No, no, not dumb at all. Having the possibility to render a semi-transparent VML rounded-rect as background would be a nice feature for sure. This would require some additional config options though. Something like:
background: {
color: '#000',
opacity: 0.7,
padding: 20,
radius: 20
}
from spin.js.
The config does make sense to me.
In my particular case I need to apply shadow, rounded corner, small border, background color and transparency... You know, to match the pixel-perfect design :)
Maybe it would be easier to provide ability style it via CSS instead? But I guess it would be relatively big change then.
from spin.js.
Yeah, but that wouldn't work in oldIEs. For now, the easiest solution would probably be to use PNG as background image on your surrounding DIV. I'll keep this issue open as feature request for spin.js 2.0.
from spin.js.
I think it would be ok not to support old IEs as long as person using this feature understands it.
I personally would really prefer CSS styling. And yeah, PNG won't work well in IE 6 unless transparency trick is applied.
So it's pretty much the same.
from spin.js.
So maybe option like: wrapperClassForModernBrowser: "spinner"
would do the job :)
from spin.js.
In modern browsers you can already select the outer DIV using div[aria-role=progressbar]
. But as you'll see, just adding a class won't be enough, since that DIV 0px high, as wide as its offsetParent, and the spinner is positioned outside of it!
In order to achieve what you want, spin.js would have to create yet another container. The complex part about that is the calculation of the correct top/left offsets. It's certainly doable, but not that trivial.
But for now I'd say it's much easier to add that wrapper div within your project's jQuery glue-code instead of implementing a generic mechanism that works in all situations.
from spin.js.
Yeah, it indeed looks like wrapping in a custom div and positioning it manually is the best way to go for now.
from spin.js.
I'm also looking for this functionality. I'm using spin.js with jquery, so it can look like $('.some_div').spin({ background: {color: 'white', opacity: '0.5'} }). So, is it a problem to position wrapper at the top: 0, left: 0 of .some_div, with dimensions of .some_div? Or it will do the trick?
from spin.js.
Just an example of using in our project:
$.fn.preloader = (mode = true) ->
block = $(this)
if mode
block.addClass 'preloader'
block.css 'opacity', '0.5'
block.spin
color: '#f18b00'
else
block.spin false
block.removeClass 'preloader'
block.css 'opacity', '1'
from spin.js.
To place animation in center off the spinner container that fills the page with a overlay is easy to do:
Change line 152 to:
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: '100%', zIndex: o.zIndex})
Change loop code from Line: 218 to
for (; i < o.lines; i++) {
seg = css(createEl(), {
position: 'absolute',
top: '50%',
left: '50%',
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
opacity: o.opacity,
animation: useCssAnimations && addAnimation(o.opacity, o.trail, i, o.lines) + ' ' + 1/o.speed + 's linear infinite'
})
Then change you spinner class to:
.spinner{
left:0;
top:0;
height:100%;
background:rgba(255,255,255,.6);
}
from spin.js.
+1
from spin.js.
Little workaound I'm using right now:
$e.addClass 'opaque'
$e.spin()
# Stop spin
$e.removeClass 'opaque'
$e.spin false
.opaque > *:not(.spinner) { opacity: 0.1 }
from spin.js.
+1 @nicooga, you are awesome :) your code did it simply & beautifully
from spin.js.
Related Issues (20)
- Spin do not show animation in UI after updating Bootstrap and jQuery HOT 2
- please make sure newest versions are CDNs. HOT 7
- Since I upgrade the script the spin does not stop anymore.. HOT 4
- Pointers on how to use in Vue HOT 1
- problem
- div issue / undefined HOT 1
- Spinner looks weird when centered on odd number parent container widths... HOT 1
- NO spin.js HOT 2
- IE 11 Spinner Not Showing HOT 2
- Need to change spinner color HOT 1
- Sveltekit Vite error: SyntaxError: Unexpected token 'export'
- browserify HOT 1
- Uncaught SyntaxError: Unexpected token 'export' (at spin.js:82:1) HOT 2
- add mask
- Improving Documentation Website Font Legibility and Design
- Spinner Percentage Not Increase Continously In Increasing Order
- How Can I Remove Spinner In Spin.js? HOT 1
- spin.js module not recognized
- Invoking spinner before a "promise" not working HOT 5
- Clarification needed: how can I run spin.js options file detailed on website?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spin.js.