I figured it out: https://jsfiddle.net/uc6vm1wb/10/
.panel.slide {
transition-delay: 2s;
transform: translateY(calc(-100% - 1px));
}
window.onload = function() {
const splashScreen = document.querySelector('.splash-screen');
splashScreen.classList.add('hide');
splashScreen.addEventListener('transitionend', function() {
splashScreen.style.display = 'none';
});
const panel = document.querySelector('.panel');
panel.classList.add('slide');
};
Is there a need for:
splashScreen.addEventListener('transitionend', function() {
It seems to work without that.
css:
.splash-screen {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
z-index: 1;
inset: 0 0 0 0;
background: black;
opacity: 1;
/* Set transition duration to 1 seconds */
pointer-events: none;
/*dissable mouse clicking */
cursor: default;
}
.splash-screen.hide {
opacity: 0;
transition-delay: 1s;
/* Add a delay of 1 seconds before the opacity changes to 0 */
pointer-events: auto;
/* Re-enable mouse clicking after 1 seconds */
cursor: default;
}
javascript: https://jsfiddle.net/uc6vm1wb/12/
window.onload = function() {
const splashScreen = document.querySelector('.splash-screen');
splashScreen.classList.add('hide');
splashScreen.addEventListener('transitionend', function() {
splashScreen.style.display = 'none';
});
From AI:
The transitionend event listener you’re referring to is used to set the display property of the .splash-screen element to none once the transition ends. This is done to ensure that the splash screen doesn’t interfere with the rest of the page once it’s hidden.
Here’s what’s happening in your code:
- When the page loads, the
.splash-screen element is visible (opacity: 1).
- The
window.onload function adds the hide class to the .splash-screen element, which changes its opacity to 0 with a transition-delay of 1s.
- Once the transition ends (i.e., the splash screen is fully transparent), the
transitionend event is fired.
- The event listener for
transitionend then sets the display of the .splash-screen element to none, effectively removing it from the document flow.
If you remove the transitionend event listener, the splash screen will still become transparent due to the opacity: 0 style, but it will remain in the document flow because its display property won’t be changed to none. This could potentially cause issues with user interaction, as the splash screen could still receive clicks or other events, even though it’s invisible.
So, based on this explanation, it’s recommended to keep the transitionend event listener in your code. It ensures that the splash screen is properly removed from the document flow once it’s no longer visible. If you’re experiencing issues or have other requirements, please provide more details so I can give a more precise answer.