mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-10 01:03:36 -05:00
Closing animation for settings.
This commit is contained in:
parent
f1966b4560
commit
fd010ed75e
2 changed files with 21 additions and 7 deletions
|
@ -3,8 +3,9 @@ import { Helmet } from "react-helmet";
|
||||||
import { Switch, useHistory, useParams } from "react-router-dom";
|
import { Switch, useHistory, useParams } from "react-router-dom";
|
||||||
|
|
||||||
import styles from "./Settings.module.scss";
|
import styles from "./Settings.module.scss";
|
||||||
|
import classNames from "classnames";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useContext, useEffect } from "preact/hooks";
|
import { useContext, useEffect, useState } from "preact/hooks";
|
||||||
|
|
||||||
import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
|
import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
|
||||||
|
|
||||||
|
@ -48,12 +49,17 @@ export function GenericSettings({
|
||||||
const theme = useContext(ThemeContext);
|
const theme = useContext(ThemeContext);
|
||||||
const { page } = useParams<{ page: string }>();
|
const { page } = useParams<{ page: string }>();
|
||||||
|
|
||||||
|
const [closing, setClosing] = useState(false);
|
||||||
function exitSettings() {
|
function exitSettings() {
|
||||||
|
setClosing(true);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
if (history.length > 0) {
|
if (history.length > 0) {
|
||||||
history.goBack();
|
history.goBack();
|
||||||
} else {
|
} else {
|
||||||
history.push("/");
|
history.push("/");
|
||||||
}
|
}
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -68,7 +74,11 @@ export function GenericSettings({
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.settings} data-mobile={isTouchscreenDevice}>
|
<div
|
||||||
|
className={classNames(styles.settings, {
|
||||||
|
[styles.closing]: closing,
|
||||||
|
})}
|
||||||
|
data-mobile={isTouchscreenDevice}>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<meta
|
<meta
|
||||||
name="theme-color"
|
name="theme-color"
|
||||||
|
|
|
@ -69,6 +69,10 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
animation: open 0.18s ease-out, opacity 0.18s;
|
animation: open 0.18s ease-out, opacity 0.18s;
|
||||||
|
|
||||||
|
&.closing {
|
||||||
|
animation: close 0.18s ease-in;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings {
|
.settings {
|
||||||
|
|
Loading…
Reference in a new issue