mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web/SmallDialog: fix rendering & performance issues, new mobile animation
This commit is contained in:
parent
2c1bd50e70
commit
cd41fc9d49
1 changed files with 49 additions and 14 deletions
|
@ -1,4 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { tick } from "svelte";
|
||||||
|
|
||||||
import { killDialog } from "$lib/dialogs";
|
import { killDialog } from "$lib/dialogs";
|
||||||
import type { DialogButton } from "$lib/types/dialog";
|
import type { DialogButton } from "$lib/types/dialog";
|
||||||
|
|
||||||
|
@ -14,10 +16,12 @@
|
||||||
let dialogParent: HTMLDialogElement;
|
let dialogParent: HTMLDialogElement;
|
||||||
|
|
||||||
let closing = false;
|
let closing = false;
|
||||||
|
let open = false;
|
||||||
|
|
||||||
const close = () => {
|
const close = () => {
|
||||||
if (dialogParent) {
|
if (dialogParent) {
|
||||||
closing = true;
|
closing = true;
|
||||||
|
open = false;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
dialogParent.close();
|
dialogParent.close();
|
||||||
killDialog();
|
killDialog();
|
||||||
|
@ -27,10 +31,13 @@
|
||||||
|
|
||||||
$: if (dialogParent) {
|
$: if (dialogParent) {
|
||||||
dialogParent.showModal();
|
dialogParent.showModal();
|
||||||
|
tick().then(() => {
|
||||||
|
open = true;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<dialog id="dialog-{id}" bind:this={dialogParent} class:closing>
|
<dialog id="dialog-{id}" bind:this={dialogParent} class:closing class:open>
|
||||||
<div class="dialog-body small-dialog" class:meowbalt-visible={meowbalt}>
|
<div class="dialog-body small-dialog" class:meowbalt-visible={meowbalt}>
|
||||||
{#if meowbalt === "error"}
|
{#if meowbalt === "error"}
|
||||||
<div class="meowbalt-container">
|
<div class="meowbalt-container">
|
||||||
|
@ -76,7 +83,7 @@
|
||||||
<style>
|
<style>
|
||||||
dialog {
|
dialog {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: none;
|
background: none;
|
||||||
|
@ -119,11 +126,19 @@
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
margin: var(--padding);
|
margin: var(--padding);
|
||||||
border-radius: 29px;
|
border-radius: 29px;
|
||||||
animation: modal-in 0.3s;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.open .small-dialog {
|
||||||
|
animation: modal-in 0.35s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.closing .small-dialog {
|
||||||
|
animation: modal-out 0.15s;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.small-dialog.meowbalt-visible {
|
.small-dialog.meowbalt-visible {
|
||||||
padding-top: 45px;
|
padding-top: 45px;
|
||||||
}
|
}
|
||||||
|
@ -133,11 +148,6 @@
|
||||||
top: -110px;
|
top: -110px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.closing .small-dialog {
|
|
||||||
animation: modal-out 0.15s;
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.body-text {
|
.body-text {
|
||||||
font-size: 14.5px;
|
font-size: 14.5px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
@ -166,19 +176,23 @@
|
||||||
#dialog-backdrop {
|
#dialog-backdrop {
|
||||||
--backdrop-opacity: 0.4;
|
--backdrop-opacity: 0.4;
|
||||||
background-color: var(--popup-backdrop);
|
background-color: var(--popup-backdrop);
|
||||||
position: absolute;
|
position: inherit;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
opacity: var(--backdrop-opacity);
|
opacity: 0;
|
||||||
animation: backdrop-in 0.15s;
|
animation: backdrop-in 0.15s;
|
||||||
backdrop-filter: blur(7px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:global([data-reduce-transparency="true"]) #dialog-backdrop {
|
:global([data-reduce-transparency="true"]) #dialog-backdrop {
|
||||||
--backdrop-opacity: 0.5;
|
--backdrop-opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.open #dialog-backdrop {
|
||||||
|
opacity: var(--backdrop-opacity);
|
||||||
|
animation: backdrop-in 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
.closing #dialog-backdrop {
|
.closing #dialog-backdrop {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
animation: backdrop-out 0.15s;
|
animation: backdrop-out 0.15s;
|
||||||
|
@ -189,13 +203,14 @@
|
||||||
transform: scale(0.8);
|
transform: scale(0.8);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
30% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
50% {
|
50% {
|
||||||
transform: scale(1.005);
|
transform: scale(1.005);
|
||||||
opacity: 1;
|
|
||||||
}
|
}
|
||||||
100% {
|
100% {
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
opacity: 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,12 +245,32 @@
|
||||||
|
|
||||||
@media screen and (max-width: 535px) {
|
@media screen and (max-width: 535px) {
|
||||||
dialog {
|
dialog {
|
||||||
align-items: end;
|
justify-content: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.small-dialog {
|
.small-dialog {
|
||||||
margin-bottom: calc(var(--padding) + env(safe-area-inset-bottom));
|
margin-bottom: calc(var(--padding) + env(safe-area-inset-bottom));
|
||||||
box-shadow: 0 0 0 2px var(--popup-stroke) inset;
|
box-shadow: 0 0 0 2px var(--popup-stroke) inset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.open .small-dialog {
|
||||||
|
animation: modal-in-mobile 0.4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes modal-in-mobile {
|
||||||
|
from {
|
||||||
|
transform: translateY(200px);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
30% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: translateY(0px);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue