From 0b43ed8bca44626c8d2f9ced15f383e4eaeacd79 Mon Sep 17 00:00:00 2001 From: Daniel <50356015+danny007in@users.noreply.github.com> Date: Fri, 14 May 2021 06:56:41 +0530 Subject: [PATCH] animation fix --- scss/parts/_core.scss | 1 + ts/adminlte.ts | 2 ++ ts/layout.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ ts/push-menu.ts | 1 + ts/sidebar-overlay.ts | 2 +- ts/treeview.ts | 3 --- 6 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 ts/layout.ts diff --git a/scss/parts/_core.scss b/scss/parts/_core.scss index 788b0f3ce..1641ad5e8 100644 --- a/scss/parts/_core.scss +++ b/scss/parts/_core.scss @@ -3,3 +3,4 @@ // @import "../layout"; +@import "../miscellaneous"; diff --git a/ts/adminlte.ts b/ts/adminlte.ts index 85003d24c..6432d718b 100644 --- a/ts/adminlte.ts +++ b/ts/adminlte.ts @@ -1,9 +1,11 @@ +import Layout from './layout' import PushMenu from './push-menu' import SidebarHover from './sidebar-hover' import SidebarOverlay from './sidebar-overlay' import Treeview from './treeview' export { + Layout, PushMenu, SidebarHover, SidebarOverlay, diff --git a/ts/layout.ts b/ts/layout.ts new file mode 100644 index 000000000..41272967c --- /dev/null +++ b/ts/layout.ts @@ -0,0 +1,43 @@ +/** + * -------------------------------------------- + * AdminLTE treeview.ts + * License MIT + * -------------------------------------------- + */ + +import { + domReady +} from './util/index' + +/** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + +const CLASS_NAME_RESIZE_ANIMATION_STOPPER = 'resize-animation-stopper' + +/** + * Class Definition + * ==================================================== + */ + +class Layout { + holdTransition(): void { + let resizeTimer: number | undefined + window.addEventListener('resize', () => { + document.body.classList.add(CLASS_NAME_RESIZE_ANIMATION_STOPPER) + clearTimeout(resizeTimer) + resizeTimer = setTimeout(() => { + document.body.classList.remove(CLASS_NAME_RESIZE_ANIMATION_STOPPER) + }, 400) + }) + } +} + +domReady(() => { + const data = new Layout() + data.holdTransition() +}) + +export default Layout diff --git a/ts/push-menu.ts b/ts/push-menu.ts index 952167cd2..2a9174ea6 100644 --- a/ts/push-menu.ts +++ b/ts/push-menu.ts @@ -78,6 +78,7 @@ class PushMenu { expand(): void { this.sidebarOpening() const bodyClass = document.body.classList + bodyClass.remove(CLASS_NAME_HEADER_MOBILE_OPEN) bodyClass.remove(CLASS_NAME_SIDEBAR_CLOSE) bodyClass.remove(CLASS_NAME_SIDEBAR_COLLAPSE) bodyClass.add(CLASS_NAME_SIDEBAR_OPEN) diff --git a/ts/sidebar-overlay.ts b/ts/sidebar-overlay.ts index 6bbb94fba..d0ec7a954 100644 --- a/ts/sidebar-overlay.ts +++ b/ts/sidebar-overlay.ts @@ -32,7 +32,7 @@ class SidebarOverlay { addSidebaBreakPoint(): void { const bodyClass = document.body.classList const widthOutput: number = window.innerWidth - if (widthOutput > Defaults.onLayouMobile) { + if (widthOutput >= Defaults.onLayouMobile) { bodyClass.remove(CLASS_NAME_LAYOUT_MOBILE) } else { bodyClass.add(CLASS_NAME_LAYOUT_MOBILE) diff --git a/ts/treeview.ts b/ts/treeview.ts index d68211cd0..c5b8d801f 100644 --- a/ts/treeview.ts +++ b/ts/treeview.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ /** * -------------------------------------------- * AdminLTE treeview.ts @@ -33,8 +32,6 @@ const Defaults = { class Treeview { open(navItem: Element | null, childNavItem: HTMLElement | null | undefined): void { - console.log('🚀 ~ file: treeview.ts ~ line 31 ~ Treeview ~ open ~ childNavItem', childNavItem) - navItem?.classList.add(CLASS_NAME_MENU_OPEN) const height: number = childNavItem?.scrollHeight ?? 0