UNPKG

framer-motion

Version:

A simple and powerful JavaScript animation library

1 lines 920 B
{"version":3,"file":"use-motion-value-event.mjs","sources":["../../../src/utils/use-motion-value-event.ts"],"sourcesContent":["\"use client\"\n\nimport { MotionValue, MotionValueEventCallbacks } from \"motion-dom\"\nimport { useInsertionEffect } from \"react\"\n\nexport function useMotionValueEvent<\n V,\n EventName extends keyof MotionValueEventCallbacks<V>\n>(\n value: MotionValue<V>,\n event: EventName,\n callback: MotionValueEventCallbacks<V>[EventName]\n) {\n /**\n * useInsertionEffect will create subscriptions before any other\n * effects will run. Effects run upwards through the tree so it\n * can be that binding a useLayoutEffect higher up the tree can\n * miss changes from lower down the tree.\n */\n useInsertionEffect(\n () => value.on(event, callback),\n [value, event, callback]\n )\n}\n"],"names":[],"mappings":";;;;AAaI;;;;;AAKG;;AAKP;;"}