summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-07-26 19:00:53 +0200
committerThomas F. K. Jorna <[email protected]>2021-07-26 19:00:53 +0200
commitc707b3af917af40a9a06639d217937bfecef9ecd (patch)
treeddef5efa34f08c48c496fc06b03f00825048ab20
parent654e71bfacc273a964a5b620e98bd504cef85460 (diff)
fixed a single typescript error
-rw-r--r--components/config.ts31
-rw-r--r--components/tweaks.tsx12
2 files changed, 19 insertions, 24 deletions
diff --git a/components/config.ts b/components/config.ts
index 7cfe85a..2153445 100644
--- a/components/config.ts
+++ b/components/config.ts
@@ -1,4 +1,16 @@
import { Easing } from '@tweenjs/tween.js'
+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'
+ }
+ options.push(name)
+ algorithms[name] = (Easing as any)[type][mode]
+ }
+}
export const initialPhysics = {
enabled: true,
@@ -33,8 +45,8 @@ export const initialPhysics = {
highlightLinkSize: 2,
highlightAnim: false,
animationSpeed: 250,
- algorithms: getAlgos(false),
- algorithmOptions: getAlgos(true),
+ algorithms: options,
+ algorithmOptions: algorithms,
algorithmName: 'CubicOut',
orphans: false,
follow: 'Local',
@@ -48,18 +60,3 @@ export const initialFilter = {
links: [],
date: [],
}
-
-function 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])
- }
- }
- return option ? options : algorithms
-}
diff --git a/components/tweaks.tsx b/components/tweaks.tsx
index 43a8ecf..90b2aea 100644
--- a/components/tweaks.tsx
+++ b/components/tweaks.tsx
@@ -407,13 +407,11 @@ export const Tweaks = (props: TweakProps) => {
setPhysics({ ...physics, algorithmName: v.target.value })
}}
>
- {physics.algorithmOptions.map((opt: string, i: number) => {
- return (
- <option key={i} value={opt}>
- {opt}
- </option>
- )
- })}
+ {physics.algorithmOptions.map((opt: string) => (
+ <option key={opt} value={opt}>
+ {opt}
+ </option>
+ ))}
</Select>
{/* <DropDownMenu
displayValue={physics.algorithmName}