Skip to content
Snippets Groups Projects
Commit 6f9a7621 authored by Olivia206's avatar Olivia206
Browse files

fixed animation

parent deadaa07
No related branches found
No related tags found
No related merge requests found
import { focusTrap } from '../utils/focus-trap'; import { focusTrap } from '../utils/focus-trap';
const CLASSES = { const CLASSES = {
modalOpened: 'has-modal-opened' modalOpened: 'has-modal-opened',
modalIsOpened: 'is-opened'
}; };
class Modal { class Modal {
...@@ -44,7 +45,6 @@ class Modal { ...@@ -44,7 +45,6 @@ class Modal {
}); });
window.addEventListener('click', (event) => { window.addEventListener('click', (event) => {
console.log(this.element)
if (event.target === this.element) { if (event.target === this.element) {
this.toggle(false); this.toggle(false);
} }
...@@ -54,9 +54,14 @@ class Modal { ...@@ -54,9 +54,14 @@ class Modal {
toggle(open = !this.state.isOpened) { toggle(open = !this.state.isOpened) {
this.state.isOpened = open; this.state.isOpened = open;
const classAction = this.state.isOpened ? 'add' : 'remove'; const classAction = this.state.isOpened ? 'add' : 'remove';
let transitionDuration = window.getComputedStyle(this.element).transitionDuration;
transitionDuration = parseFloat(transitionDuration.replace('s', ''));
this.element.setAttribute('aria-hidden', !this.state.isOpened); this.element.setAttribute('aria-hidden', !this.state.isOpened);
document.documentElement.classList[classAction](CLASSES.modalOpened); document.documentElement.classList[classAction](CLASSES.modalOpened);
setTimeout(() => {
this.element.classList[classAction](CLASSES.modalIsOpened);
}, transitionDuration * 1000);
} }
} }
......
...@@ -92,7 +92,6 @@ details ...@@ -92,7 +92,6 @@ details
transform: translateY(-5px) transform: translateY(-5px)
.modal .modal
align-items: center align-items: center
display: flex
justify-content: center justify-content: center
height: 100vh height: 100vh
left: 0 left: 0
...@@ -102,6 +101,14 @@ details ...@@ -102,6 +101,14 @@ details
width: 100% width: 100%
margin: 0 margin: 0
z-index: $zindex-modal z-index: $zindex-modal
opacity: 0
transition: opacity $header-transition
html.is-animating &
opacity: 0
display: flex
&.is-opened
opacity: 1
display: flex
&[aria-hidden="true"] &[aria-hidden="true"]
display: none display: none
.modal-content .modal-content
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment