How to use the @moveable/matrix.createIdentityMatrix 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 createIdentityMatrix3() {
    return createIdentityMatrix(3);
}
github daybrush / moveable / packages / react-moveable / src / react-moveable / utils.ts View on Github external
if (tagName === "g") {
                offsetLeft = 0;
                offsetTop = 0;
            } else {
                [
                    offsetLeft, offsetTop, origin[0], origin[1],
                ] = getSVGGraphicsOffset(el as SVGGraphicsElement, origin);
            }
        } else {
            origin = getTransformOrigin(style).map(pos => parseFloat(pos));
        }
        if (tagName === "svg" && targetMatrix) {
            matrixes.push(
                getSVGMatrix(el as SVGSVGElement, n),
                createIdentityMatrix(n),
            );
        }
        const {
            offsetParent,
            isEnd: isOffsetEnd,
            isStatic,
        } = getOffsetInfo(el, container);

        if (isWebkit && !hasNotOffset && !isSVG && isStatic && position === "relative") {
            offsetLeft -= offsetParent.offsetLeft;
            offsetTop -= offsetParent.offsetTop;

            isEnd = isEnd || isOffsetEnd;
        }
        let parentClientLeft = 0;
        let parentClientTop = 0;
github daybrush / moveable / packages / react-moveable / src / react-moveable / ables / Warpable.tsx View on Github external
datas.warpTargetMatrix = is3d ? targetMatrix : convertDimension(targetMatrix, 3, 4);
        datas.targetInverseMatrix = ignoreDimension(invert(datas.warpTargetMatrix, 4), 3, 4);
        datas.direction = direction;
        datas.left = left;
        datas.top = top;

        setDragStart(moveable, { datas });
        datas.poses = [
            [0, 0],
            [width, 0],
            [0, height],
            [width, height],
        ].map((p, i) => minus(p, transformOrigin));

        datas.nextPoses = datas.poses.map(([x, y]: number[]) => caculate(datas.warpTargetMatrix, [x, y, 0, 1], 4));
        datas.startMatrix = createIdentityMatrix(4);
        datas.prevMatrix = createIdentityMatrix(4);
        datas.absolutePoses = getAbsolutePosesByState(state);
        datas.posIndexes = getPosIndexesByDirection(direction);
        state.snapDirection = direction;

        const params = fillParams(moveable, e, {
            set: (matrix: number[]) => {
                datas.startMatrix = matrix;
            },
        });
        const result = triggerEvent(moveable, "onWarpStart", params);
        if (result !== false) {
            datas.isWarp = true;
        }
        return datas.isWarp;
    },
github daybrush / moveable / packages / react-moveable / src / react-moveable / utils.ts View on Github external
targetMatrix = matrix;
        }
        if (!transformOrigin) {
            transformOrigin = origin;
        }
        if (isEnd || isFixed) {
            break;
        } else {
            el = offsetParent;
            isEnd = isOffsetEnd;
        }

    }
    let mat = prevMatrix ? convertDimension(prevMatrix, prevN!, n) : createIdentityMatrix(n);
    let beforeMatrix = prevMatrix ? convertDimension(prevMatrix, prevN!, n) : createIdentityMatrix(n);
    let offsetMatrix = createIdentityMatrix(n);
    const length = matrixes.length;
    const endContainer = getOffsetInfo(originalContainer, originalContainer, true).offsetParent;

    matrixes.reverse();
    matrixes.forEach((matrix, i) => {
        if (length - 2 === i) {
            beforeMatrix = mat.slice();
        }
        if (length - 1 === i) {
            offsetMatrix = mat.slice();
        }

        if (isObject(matrix[n - 1])) {
            [matrix[n - 1], matrix[2 * n - 1]] =
                getSVGOffset(
                    matrix[n - 1] as any,