mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
Show at least one decimal digit
This commit is contained in:
@@ -5,7 +5,7 @@ import TypeInitialization from "./entity/TypeInitialization"
|
||||
export default class Utility {
|
||||
|
||||
static sigmoid(x, curvature = 1.7) {
|
||||
return 1 / (1 + (x / Math.pow(1 - x, -curvature)))
|
||||
return 1 / (1 + (x / (1 - x) ** -curvature))
|
||||
}
|
||||
|
||||
static clamp(val, min, max) {
|
||||
@@ -16,6 +16,19 @@ export default class Utility {
|
||||
return Number(getComputedStyle(element).getPropertyValue("--ueb-scale"))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} num
|
||||
* @param {Number} decimals
|
||||
*/
|
||||
static minDecimals(num, decimals = 1) {
|
||||
const powered = num * 10 ** decimals
|
||||
if (Math.abs(powered % 1) > Number.EPSILON) {
|
||||
// More decimal digits than required
|
||||
return num.toString()
|
||||
}
|
||||
return num.toFixed(decimals)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number[]} viewportLocation
|
||||
* @param {HTMLElement} movementElement
|
||||
|
||||
Reference in New Issue
Block a user