@mocanvas/editor · function

useTransform

declare function useTransform(ref: RefObject<HTMLElement | SVGElement | null>, x?: number, y?: number, scale?: number, rotate?: number, additionalOffset?: {
    x: number;
    y: number;
}): void

Write a page-to-screen transform onto an element.

The order — translate, then scale, then rotate — is the order the editor composes a shape's own transform in, so a value taken from editor.getShapePageTransform() can be handed straight through.

Passing undefined for x (or y) clears the transform, which is how a component says "not positioned yet" without unmounting.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.