(
{ top, left, width, height }: Dimensions,
setSize = true,
roundVals = true,
zIndex?: number | string
)
| 59 | } |
| 60 | |
| 61 | export function setTransform( |
| 62 | { top, left, width, height }: Dimensions, |
| 63 | setSize = true, |
| 64 | roundVals = true, |
| 65 | zIndex?: number | string |
| 66 | ): CSSProperties { |
| 67 | // Replace unitless items with px |
| 68 | const topRounded = roundVals ? Math.floor(top) : top; |
| 69 | const leftRounded = roundVals ? Math.floor(left) : left; |
| 70 | const widthRounded = roundVals ? Math.ceil(width) : width; |
| 71 | const heightRounded = roundVals ? Math.ceil(height) : height; |
| 72 | const translate = `translate3d(${leftRounded}px,${topRounded}px, 0)`; |
| 73 | return { |
| 74 | top: 0, |
| 75 | left: 0, |
| 76 | transform: translate, |
| 77 | width: setSize ? `${widthRounded}px` : undefined, |
| 78 | height: setSize ? `${heightRounded}px` : undefined, |
| 79 | position: "absolute", |
| 80 | zIndex: zIndex, |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | export function getCenter(dimensions: Dimensions): Point { |
| 85 | return { |
no outgoing calls
no test coverage detected