diff options
author | Eric Bailey <git@esb.lol> | 2025-06-24 22:03:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-24 22:03:23 -0500 |
commit | 4c1515169af81f5eb861e476d2bc07f17c8635fd (patch) | |
tree | 37be0de4769da65b3afde1cd1f890afecde14f3b /src/components/hooks | |
parent | cd820709b611a0381222a34d2bc6ff49fa380452 (diff) | |
download | voidsky-4c1515169af81f5eb861e476d2bc07f17c8635fd.tar.zst |
Tooltip (#8555)
* Working overlay, WIP * Ok working with no overlay and global gesture handler * Ok pretty good on native * Cleanup * Cleanup * add animation * add transform origin to animation * Some a11y * Improve colors * Explicitly wrap gesture handler * Add easier abstraction * Web * Fix animation * Cleanup and remove provider * Include demo for now * Ok diff interface to avoid collapsed views * Use dimensions hook * Adjust overlap, clarify intent of consts * Revert testing edits --------- Co-authored-by: Samuel Newman <mozzius@protonmail.com>
Diffstat (limited to 'src/components/hooks')
-rw-r--r-- | src/components/hooks/useOnGesture/index.ts | 24 | ||||
-rw-r--r-- | src/components/hooks/useOnGesture/index.web.ts | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/components/hooks/useOnGesture/index.ts b/src/components/hooks/useOnGesture/index.ts new file mode 100644 index 000000000..6f0560661 --- /dev/null +++ b/src/components/hooks/useOnGesture/index.ts @@ -0,0 +1,24 @@ +import {useEffect} from 'react' + +import { + type GlobalGestureEvents, + useGlobalGestureEvents, +} from '#/state/global-gesture-events' + +/** + * Listen for global gesture events. Callback should be wrapped with + * `useCallback` or otherwise memoized to avoid unnecessary re-renders. + */ +export function useOnGesture( + onGestureCallback: (e: GlobalGestureEvents['begin']) => void, +) { + const ctx = useGlobalGestureEvents() + useEffect(() => { + ctx.register() + ctx.events.on('begin', onGestureCallback) + return () => { + ctx.unregister() + ctx.events.off('begin', onGestureCallback) + } + }, [ctx, onGestureCallback]) +} diff --git a/src/components/hooks/useOnGesture/index.web.ts b/src/components/hooks/useOnGesture/index.web.ts new file mode 100644 index 000000000..6129fde10 --- /dev/null +++ b/src/components/hooks/useOnGesture/index.web.ts @@ -0,0 +1 @@ +export function useOnGesture() {} |