How to use the framesync.getFrameData function in framesync

To help you get started, we’ve selected a few framesync 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 framer / motion / src / gestures / use-pan-gesture.ts View on Github external
function onPointerDown(
        event: MouseEvent | TouchEvent | PointerEvent,
        info: EventInfo
    ) {
        // If we have more than one touch, don't start detecting this gesture
        if (isTouchEvent(event) && event.touches.length > 1) return

        const initialInfo = transformPoint(info)
        const { point } = initialInfo

        const { timestamp } = getFrameData()
        session.current = {
            target: event.target,
            pointHistory: [{ ...point, timestamp }],
        }

        const { onPanSessionStart } = handlersRef.current

        onPanSessionStart && onPanSessionStart(event, getPanInfo(initialInfo))

        removePointerEvents()

        const removeOnPointerMove = addPointerEvent(
            window,
            "pointermove",
            onPointerMove
        )
github framer / motion / src / gestures / use-pan-gesture.ts View on Github external
cancelPan()
            return
        }

        const info = getPanInfo(lastMoveEventInfo.current)
        const panStarted = session.current.startEvent !== undefined

        // Only start panning if the offset is larger than 3 pixels. If we make it
        // any larger than this we'll want to reset the pointer history
        // on the first update to avoid visual snapping to the cursoe.
        const distancePastThreshold = distance(info.offset, { x: 0, y: 0 }) >= 3

        if (!panStarted && !distancePastThreshold) return

        const { point } = info
        const { timestamp } = getFrameData()
        session.current.pointHistory.push({ ...point, timestamp })

        const { onPanStart, onPan } = handlersRef.current

        if (!panStarted) {
            onPanStart && onPanStart(lastMoveEvent.current, info)
            session.current.startEvent = lastMoveEvent.current
        }

        onPan && onPan(lastMoveEvent.current, info)
    }
github Popmotion / popmotion / packages / popcorn / src / utils / smooth.ts View on Github external
return (v: number) => {
    const currentFramestamp = getFrameData().timestamp;
    const timeDelta =
      currentFramestamp !== lastUpdated ? currentFramestamp - lastUpdated : 0;
    const newValue = timeDelta
      ? smoothFrame(previousValue, v, timeDelta, strength)
      : previousValue;
    lastUpdated = currentFramestamp;
    previousValue = newValue;
    return newValue;
  };
};
github Popmotion / popmotion / packages / popmotion / src / reactions / value.ts View on Github external
update(v: Value) {
    super.update(v);
    this.prev = this.current;
    this.updateCurrent(v);
    const { delta, timestamp } = getFrameData();
    this.timeDelta = delta;
    this.lastUpdated = timestamp;
    sync.postRender(this.scheduleVelocityCheck);
  }
github Popmotion / popmotion / packages / popmotion / src / transformers.ts View on Github external
return (v: number) => {
    const currentFramestamp = getFrameData().timestamp;
    const timeDelta =
      currentFramestamp !== lastUpdated ? currentFramestamp - lastUpdated : 0;
    const newValue = timeDelta
      ? calcSmoothing(v, previousValue, timeDelta, strength)
      : previousValue;
    lastUpdated = currentFramestamp;
    previousValue = newValue;
    return newValue;
  };
};