All files / src/render/html/utils transform.ts

100% Statements 14/14
100% Branches 0/0
100% Functions 5/5
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45        43x           43x         43x 43x 172x 688x             43x 272x           43x 43x 2741x           43x 43x 1090x    
/**
 * A list of all transformable axes. We'll use this list to generated a version
 * of each axes for each transform.
 */
export const transformAxes = ["", "X", "Y", "Z"]
 
/**
 * An ordered array of each transformable value. By default, transform values
 * will be sorted to this order.
 */
const order = ["translate", "scale", "rotate", "skew"]
 
/**
 * Generate a list of every possible transform key.
 */
export const transformProps = ["transformPerspective", "x", "y", "z"]
order.forEach((operationKey) =>
    transformAxes.forEach((axesKey) =>
        transformProps.push(operationKey + axesKey)
    )
)
 
/**
 * A function to use with Array.sort to sort transform keys by their default order.
 */
export function sortTransformProps(a: string, b: string) {
    return transformProps.indexOf(a) - transformProps.indexOf(b)
}
 
/**
 * A quick lookup for transform props.
 */
const transformPropSet = new Set(transformProps)
export function isTransformProp(key: string) {
    return transformPropSet.has(key)
}
 
/**
 * A quick lookup for transform origin props
 */
const transformOriginProps = new Set(["originX", "originY", "originZ"])
export function isTransformOriginProp(key: string) {
    return transformOriginProps.has(key)
}