弹出层过渡动画
This commit is contained in:
parent
08ddae09f9
commit
e7c81574a8
@ -54,6 +54,8 @@ export function Dialog(options) {
|
|||||||
backdrop-filter: blur(5px);
|
backdrop-filter: blur(5px);
|
||||||
duration: 0.5s;
|
duration: 0.5s;
|
||||||
transition: all 0.5s;
|
transition: all 0.5s;
|
||||||
|
opacity: 0;
|
||||||
|
animation: fadeIn 0.75s forwards;
|
||||||
`
|
`
|
||||||
content.classList.add('dialog')
|
content.classList.add('dialog')
|
||||||
content.style.cssText = `
|
content.style.cssText = `
|
||||||
@ -69,10 +71,26 @@ export function Dialog(options) {
|
|||||||
`
|
`
|
||||||
element.appendChild(content)
|
element.appendChild(content)
|
||||||
// 点击空白处关闭
|
// 点击空白处关闭
|
||||||
element.onclick = event => {
|
element.onclick = async event => {
|
||||||
if (event.target === element) {
|
if (event.target === element) {
|
||||||
|
await element.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 100 }).finished
|
||||||
element.remove()
|
element.remove()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fadeIn = `
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
// Add the CSS3 animation to the document's head
|
||||||
|
const style = document.createElement('style')
|
||||||
|
style.innerHTML = fadeIn
|
||||||
|
document.head.appendChild(style)
|
Loading…
Reference in New Issue
Block a user