From 761eef9a720b8fb85786ba4dc84805fdcc0d7d48 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Mon, 27 Jun 2022 15:06:50 +1000 Subject: Make transition-on-tree-change less abrupt --- src/App.vue | 3 ++- src/util.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/App.vue b/src/App.vue index 4096ec0..d6c1d7a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -86,7 +86,7 @@ import HelpIcon from './components/icon/HelpIcon.vue'; import {TolNode, TolMap, Action, UiOptions} from './lib'; import {LayoutNode, LayoutOptions, LayoutTreeChg} from './layout'; import {initLayoutTree, initLayoutMap, tryLayout} from './layout'; -import {getServerResponse, getBreakpoint, getScrollBarWidth, arraySum, randWeightedChoice} from './util'; +import {getServerResponse, getBreakpoint, getScrollBarWidth, arraySum, randWeightedChoice, timeout} from './util'; // Type representing auto-mode actions type AutoAction = 'move across' | 'move down' | 'move up' | Action; @@ -730,6 +730,7 @@ export default defineComponent({ await this.onDetachedAncestorClick(this.layoutTree); } await this.onNonleafClick(this.layoutTree); + await timeout(this.uiOpts.transitionDuration); await this.initTreeFromServer(); }, onResetSettings(): void { diff --git a/src/util.ts b/src/util.ts index 6d713a8..1ed019c 100644 --- a/src/util.ts +++ b/src/util.ts @@ -151,3 +151,7 @@ export function capitalizeWords(str: string){ str = str.replace(/(\w)'S/, '$1\'s'); // Avoid cases like "traveler's tree" -> "Traveler'S Tree" return str; } +// Used to async-await for until after a timeout +export async function timeout(ms: number){ + return new Promise(resolve => setTimeout(resolve, ms)) +} -- cgit v1.2.3