graingert / WOW

Reveal CSS animation as you scroll down a page
https://wowjs.uk
Other
1.58k stars 1.56k forks source link

What about wow when JS fails? #27

Open jgugelot opened 4 years ago

jgugelot commented 4 years ago

To prevent elements from 1st showing, then disappearing and then appearing again (animation) when using wow, I added the CSs line: .wow { visibility:none;}

However, this causes elements to stay hidden when JS fails or disabled in browser. For that, I created this little

<!-- wow backup -->
<noscript><style>.wow {visibility: initial;}</style></noscript>
<script>window.onload=function(){elem = document.querySelector('.wow');style = getComputedStyle(elem);if (style.visibility=='hidden') {style = document.createElement('style');document.head.appendChild(style);style.sheet.insertRule('.wow { visibility:initial;}');}}</script>
hidegh commented 1 year ago

Trying to solve similar issue with AOS.js (actually dopping the use of it).

We need an wow-initialized class. Actually we can request this feature, but until then I'd suggest this solution:

hidegh commented 1 year ago

FEATURE REQUEST: ❗we require a new option: initializedClassName that should be set to all .wow containers and to all newly detected containers. In reg. to this feature, we should also alter the CSS of the .wow - only .wow.wow-initialized should have the visibility: hidden set.

In case WOW.js load fails, this class then would not be appended, which would result in the element still being shown as intended in case no animation would be added.