@react-md/utils
Version:
General utils for react-md.
52 lines • 1.32 kB
JavaScript
/**
* This is a simple util that'll generate a css `transform-origin` string so
* that the fixed element can animate from the correct point based on the
* provided anchor.
*
* @param options - The anchor that should be used to create the transform origin
* for.
* @returns the transform origin string
* @internal
*/
export function getTransformOrigin(options) {
var yPosition = options.transformOriginY;
var x = "0";
switch (options.x) {
case "right":
case "inner-left":
x = "0";
break;
case "center":
x = "50%";
break;
case "left":
case "inner-right":
x = "100%";
break;
default:
x = "0";
}
var y = "0";
if (typeof yPosition === "number") {
y = "".concat(yPosition, "px");
}
else {
switch (options.y) {
case "above":
case "bottom":
y = "100%";
break;
case "center":
y = "50%";
break;
case "below":
case "top":
y = "0";
break;
default:
y = "0";
}
}
return "".concat(x, " ").concat(y);
}
//# sourceMappingURL=getTransformOrigin.js.map