@symbo.ls/scratch
Advanced tools
Comparing version 0.7.19 to 0.7.20
@@ -5,3 +5,3 @@ { | ||
"author": "symbo.ls", | ||
"version": "0.7.19", | ||
"version": "0.7.20", | ||
"files": [ | ||
@@ -8,0 +8,0 @@ "src" |
@@ -19,3 +19,4 @@ 'use strict' | ||
export * from './cases' | ||
export * from './animation' | ||
export const RESET = {} |
@@ -41,3 +41,4 @@ 'use strict' | ||
reset: setSameValue, | ||
unit: setSameValue | ||
unit: setSameValue, | ||
animation: setSameValue | ||
} | ||
@@ -44,0 +45,0 @@ |
'use strict' | ||
import { toDashCase } from '@symbo.ls/utils' | ||
import { UNIT } from '../defaultConfig' | ||
import { SEQUENCE, SPACING, UNIT } from '../defaultConfig' | ||
import { CONFIG } from '../factory' | ||
@@ -85,2 +85,16 @@ import { isString } from './object' | ||
const switchSequenceOnNegative = (key, base, ratio) => { | ||
const values = Object.values(SEQUENCE) | ||
const index = values.indexOf(ratio) | ||
const diffRatio = ratio / SPACING.ratio | ||
const total = values[values.length - 1] - values[0] | ||
const avg = total / 2 | ||
const diff = avg - ratio | ||
const scale = total / ratio | ||
const finalDiff = avg + avg / diffRatio | ||
// if (key < 0) return base * Math.pow(avg, key) | ||
return base * Math.pow(ratio, key) | ||
} | ||
export const generateSequence = (sequenceProps) => { | ||
@@ -94,4 +108,4 @@ const { type, base, ratio, range, subSequence } = sequenceProps | ||
const letterKey = numToLetterMap[key] | ||
const value = base * Math.pow(ratio, key) | ||
const scaling = ~~(value / base * 1000) / 1000 | ||
const value = switchSequenceOnNegative(key, base, ratio) | ||
const scaling = ~~(value / base * 100) / 100 | ||
const variable = prefix + letterKey | ||
@@ -98,0 +112,0 @@ |
43066
38
1310