I run into this problem in every single project, and I'm fed up enough at this point to ask.
I'm wanting to use css3 for fade animations on things because of how nice and smooth it is compared to fadeIn, etc.
The problem is, 99% of the time I'm fading in something that is initially set to display:none;
(meaning, just having it at opacity: 0
to start, and changing it to opacity: 1
with jQuery isn't good enough.
For example, for my drag and drop functionality, I have an absolute positioned div: #dropzone
, and that obviously can't be covering the entire app (but just set to zero opacity the whole time).
If I try adding $('#dropzone').show().css('opacity',1)
there is no fade.
When it finishes .show()
, it's still set to opacity 0
(I know because if I stop it right there, nothing shows up. It's set to display:block
with opacity: 0
) -- it also already has the proper css3 transition
properties on it, so why would it not animate by the time it hits .css()
?
This has plagued me so much, I would love to fix this or know the proper way.
Thanks
edit added jsfiddle