How to use the @popmotion/popcorn.angle function in @popmotion/popcorn

To help you get started, we’ve selected a few @popmotion/popcorn 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 Popmotion / popmotion / packages / popmotion / src / input / multitouch / index.ts View on Github external
const updatePoint = () => {
      if (isGesture) {
        const [firstTouch, secondTouch] = points;
        const newDistance = distance(firstTouch, secondTouch);
        const newRotation = angle(firstTouch, secondTouch);

        output.scale = scale * (newDistance / initialDistance);
        output.rotate = rotate + (newRotation - initialRotation);
      }

      update(output);
    };
github Popmotion / popmotion / packages / popmotion / src / input / multitouch / index.ts View on Github external
action(({ update }) => {
    const output = {
      touches: points,
      scale,
      rotate
    };

    let initialDistance = 0.0;
    let initialRotation = 0.0;

    const isGesture = points.length > 1;

    if (isGesture) {
      const [firstTouch, secondTouch] = points;
      initialDistance = distance(firstTouch, secondTouch);
      initialRotation = angle(firstTouch, secondTouch);
    }

    const updatePoint = () => {
      if (isGesture) {
        const [firstTouch, secondTouch] = points;
        const newDistance = distance(firstTouch, secondTouch);
        const newRotation = angle(firstTouch, secondTouch);

        output.scale = scale * (newDistance / initialDistance);
        output.rotate = rotate + (newRotation - initialRotation);
      }

      update(output);
    };

    const onMove = (e: TouchEvent) => {