tiny-vue_version0/examples/sites/tiny-uno/rules/keyframes/help.js

22 lines
475 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 辅助方法
* unit从from中分离出的单位
* mid传入一个数字 返回按百分比计算在 from~to中的位置值
* @param {string} from
* @param {string} to
* @returns Object:{ min,max,unit,mid}
*/
export default function (from, to) {
let min = parseFloat(from)
let max = parseFloat(to)
let unit = from.replace(min.toString(), '')
let mid = (v) => ((max - min) / 100) * v + min
return {
min,
max,
unit,
mid
}
}