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

Add html class after all assets are loaded for a page #423

Closed
swashbuck opened this issue Aug 1, 2023 · 2 comments · Fixed by #435
Closed

Add html class after all assets are loaded for a page #423

swashbuck opened this issue Aug 1, 2023 · 2 comments · Fixed by #435

Comments

@swashbuck
Copy link
Contributor

swashbuck commented Aug 1, 2023

Subject of the enhancement

To help with the timing of CSS animations, it would be useful to have an html class that indicates when all assets have been loaded for a page.

Use case

I want to animate the title element as soon as the page is loaded and the loading screen is removed. There is currently not a way to know when the loading screen is removed, so it's difficult to know when the animation should be triggered. For instance, there is a chance that the animation is triggered while the loading screen is still overlapping the content, so the animation will never be seen. With a new class like page-view-ready, I can do the following:

.page__title {
  transition: 0.5s all ease-in-out;
}

html.page-view-ready .page__title {
  color: fuchsia;
  transform: scale(1.05) rotate(-1deg) translate(1rem, -1rem);
}
page-view-ready.mp4
@swashbuck swashbuck self-assigned this Aug 1, 2023
@swashbuck swashbuck transferred this issue from adaptlearning/adapt-contrib-vanilla Aug 2, 2023
@swashbuck
Copy link
Contributor Author

swashbuck commented Aug 9, 2023

@oliverfoster Per your comments, I was going to add this to core/js/router.js. It makes sense to add it to showLoading() and hideLoading() because the purpose of the class is to know when the loading screen has been removed.

However, hideLoading() is seemingly never called. Instead, specific scripts (ex. Core's contentObjectView.js, Language Picker's languagePickerView.js, Spoor's wrapper.js) directly hide the loading layer with $('.js-loading').hide(). So, unfortunately, this cannot reliably be used.

Would it be better to update those other locations (ex. Language Picker) so that they always hide the loading screen via the router methods? Or should I look into your other suggestion about adding this to isReady() in core/js/views/contentObjectView.js?

@swashbuck swashbuck moved this from Needs Reviewing to Assigned in adapt_framework: The TODO Board Aug 9, 2023
@swashbuck swashbuck moved this from Assigned to Awaiting Response in adapt_framework: The TODO Board Aug 11, 2023
@swashbuck swashbuck moved this from Awaiting Response to Needs Reviewing in adapt_framework: The TODO Board Aug 28, 2023
@github-project-automation github-project-automation bot moved this from Needs Reviewing to Recently Released in adapt_framework: The TODO Board Sep 12, 2023
github-actions bot pushed a commit that referenced this issue Sep 12, 2023
# [6.40.0](v6.39.6...v6.40.0) (2023-09-12)

### New

* Add html classes depending on the loading screen's visibility (fixes #423) ([b2c2335](b2c2335)), closes [#423](#423)
@oliverfoster
Copy link
Member

🎉 This issue has been resolved in version 6.40.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants