How to use the @moveable/matrix.createOriginMatrix function in @moveable/matrix

To help you get started, we’ve selected a few @moveable/matrix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daybrush / moveable / packages / react-moveable / src / react-moveable / utils.ts View on Github external
export function getAbsoluteMatrix(matrix: number[], n: number, origin: number[]) {

    return multiplies(
        n,
        createOriginMatrix(origin, n),
        matrix,
        createOriginMatrix(origin.map(a => -a), n),
    );
}
export function measureSVGSize(el: SVGElement, unit: string, isHorizontal: boolean) {
github daybrush / moveable / packages / react-moveable / src / react-moveable / utils.ts View on Github external
export function getAbsoluteMatrix(matrix: number[], n: number, origin: number[]) {

    return multiplies(
        n,
        createOriginMatrix(origin, n),
        matrix,
        createOriginMatrix(origin.map(a => -a), n),
    );
}
export function measureSVGSize(el: SVGElement, unit: string, isHorizontal: boolean) {
github daybrush / moveable / packages / react-moveable / src / react-moveable / utils.ts View on Github external
rectLeft + prevOrigin[0] * rectWidth / prevWidth,
        rectTop + prevOrigin[1] * rectHeight / prevHeight,
    ];
    const offset = [0, 0];
    let count = 0;

    while (++count < 10) {
        const inverseBeforeMatrix = invert(beforeMatrix, n);
        [offset[0], offset[1]] = minus(
            caculatePosition(inverseBeforeMatrix, rectOrigin, n),
            caculatePosition(inverseBeforeMatrix, posOrigin, n),
        );
        const mat2 = multiplies(
            n,
            beforeMatrix,
            createOriginMatrix(offset, n),
            absoluteMatrix,
        );
        const {
            left: nextLeft,
            top: nextTop,
        } = caculateRect(mat2, width, height, n);
        const distLeft = nextLeft - rectLeft;
        const distTop = nextTop - rectTop;

        if (Math.abs(distLeft) < 2 && Math.abs(distTop) < 2) {
            break;
        }
        rectOrigin[0] -= distLeft;
        rectOrigin[1] -= distTop;
    }
    return offset.map(p => Math.round(p));
github daybrush / moveable / packages / react-moveable / src / react-moveable / utils.ts View on Github external
if (isWebkit && !hasNotOffset && !isSVG && isStatic && position === "relative") {
            offsetLeft -= offsetParent.offsetLeft;
            offsetTop -= offsetParent.offsetTop;

            isEnd = isEnd || isOffsetEnd;
        }
        let parentClientLeft = 0;
        let parentClientTop = 0;

        if (!hasNotOffset && offsetContainer !== offsetParent) {
            parentClientLeft = offsetParent.clientLeft;
            parentClientTop = offsetParent.clientTop;
        }
        matrixes.push(
            getAbsoluteMatrix(matrix, n, origin),
            createOriginMatrix([
                (hasNotOffset ? el : offsetLeft - el.scrollLeft + parentClientLeft) as any,
                (hasNotOffset ? origin : offsetTop - el.scrollTop + parentClientTop) as any,
            ], n),
        );
        if (!targetMatrix) {
            targetMatrix = matrix;
        }
        if (!transformOrigin) {
            transformOrigin = origin;
        }
        if (isEnd || isFixed) {
            break;
        } else {
            el = offsetParent;
            isEnd = isOffsetEnd;
        }