From 790b0cd2057ee9467c1f5cad5143d79830de484f Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Sat, 24 Jul 2021 21:07:00 +0200 Subject: fixed animations not working --- pages/index.tsx | 87 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 25 deletions(-) (limited to 'pages/index.tsx') diff --git a/pages/index.tsx b/pages/index.tsx index f1f9349..a59bd81 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -69,18 +69,20 @@ export type Scope = { nodeIds: string[] } -const options: string[] = [] -const algorithms: { [name: string]: (percent: number) => number } = {} - -for (let type in Easing) { - for (let mode in (Easing as any)[type]) { - let name = type + mode - if (name === 'LinearNone') { - name = 'Linear' +const getAlgos = (option?: boolean) => { + const options: string[] = [] + const algorithms: { [name: string]: (percent: number) => number } = {} + for (let type in Easing) { + for (let mode in (Easing as any)[type]) { + let name = type + mode + if (name === 'LinearNone') { + name = 'Linear' + } + option ? options.push(name) : (algorithms[name] = (Easing as any)[type][mode]) } - options.push(name) - algorithms[name] = (Easing as any)[type][mode] + console.log(algorithms) } + return option ? options : algorithms } const initialPhysics = { enabled: true, @@ -115,8 +117,8 @@ const initialPhysics = { highlightLinkSize: 2, highlightAnim: false, animationSpeed: 250, - algorithms: algorithms, - algorithmOptions: options, + algorithms: getAlgos(false), + algorithmOptions: getAlgos(true), algorithmName: 'CubicOut', orphans: false, follow: 'Local', @@ -175,6 +177,12 @@ export function GraphPage() { const orgRoamGraphDataClone = JSON.parse(JSON.stringify(orgRoamGraphData)) setGraphData(orgRoamGraphDataClone) }) + .catch((error) => { + console.log( + 'Oopsie whoopsie! We made a fucky wucky! Are you suwu owg-woam-uwui is wunning?', + error, + ) + }) } useEffect(() => { @@ -535,6 +543,13 @@ export const Tweaks = (props: TweakProps) => { divider={} align="stretch" > + setPhysics({ ...physics, colorful: !physics.colorful })} + value={physics.colorful} + > + Child + { />