aboutsummaryrefslogtreecommitdiffstats
path: root/htdocs/src/js/utilities
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-10-26 14:44:11 +0200
committerArmand Philippot <git@armandphilippot.com>2021-10-26 14:44:11 +0200
commit06a912858b059697292b6579498eb04746aff51f (patch)
tree7416b030d86ba0b885cf224f04797982bfc42d85 /htdocs/src/js/utilities
parentbfb1566c7c353d71561fb2a27bee18513dab18d3 (diff)
refactor: move animation functions to a separated file
App.js becomes heavy. So by moving some functions outside this file, it improves the readability.
Diffstat (limited to 'htdocs/src/js/utilities')
-rw-r--r--htdocs/src/js/utilities/animations.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/htdocs/src/js/utilities/animations.js b/htdocs/src/js/utilities/animations.js
new file mode 100644
index 0000000..9a30685
--- /dev/null
+++ b/htdocs/src/js/utilities/animations.js
@@ -0,0 +1,45 @@
+/**
+ * Change the element classes to hide it with a slide out left animation.
+ * @param {HTMLElement} el - The HTMLElement to hide.
+ */
+function hideToLeft(el) {
+ el?.classList.remove('slide-in--left');
+ el?.classList.add('slide-out--left');
+ setTimeout(() => {
+ el?.classList.add('hide');
+ }, 800);
+}
+
+/**
+ * Change the element classes to show it with a slide in left animation.
+ * @param {HTMLElement} el - The HTMLElement to show.
+ */
+function showFromLeft(el) {
+ el?.classList.remove('slide-out--left');
+ el?.classList.remove('hide');
+ el?.classList.add('slide-in--left');
+}
+
+/**
+ * Change the element classes to hide it with a slide out bottom animation.
+ * @param {HTMLElement} el - The HTMLElement to hide.
+ */
+function hideToBottom(el) {
+ el?.classList.remove('slide-in--up');
+ el?.classList.add('slide-out--bottom');
+ setTimeout(() => {
+ el?.classList.add('hide');
+ }, 800);
+}
+
+/**
+ * Change the element classes to show it with a slide in up animation.
+ * @param {HTMLElement} el - The HTMLElement to show.
+ */
+function showFromBottom(el) {
+ el?.classList.remove('slide-out--bottom');
+ el?.classList.remove('hide');
+ el?.classList.add('slide-in--up');
+}
+
+export { hideToLeft, showFromLeft, hideToBottom, showFromBottom };