feat: Add CameraGestureObserver - reliable alternative to onMapIdle - #4074
Merged
Conversation
Add native CameraGestureObserver component that detects when the map
has reached a steady state (no active gestures or animations).
Features:
- Emits onMapSteady event with reasons: 'steady' or 'timeout'
- Configurable quiet period (default 200ms) and max interval
- Returns last gesture type and idle duration
- Production-ready iOS and Android implementations
Example usage:
<CameraGestureObserver
quietPeriodMs={200}
maxIntervalMs={5000}
onMapSteady={({ nativeEvent }) => {
console.log('Map is steady:', nativeEvent.reason);
}}
/>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add JSDoc comments to CameraGestureObserver props - Run yarn generate to update docs - Export OnMapSteadyEvent type for better TypeScript support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add addGestureDelegate/removeGestureDelegate methods - Support multiple gesture observers via NSHashTable - Forward gesture events to all registered delegates - Required for CameraGestureObserver to receive gesture events 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add CameraGestureObserver.tsx example demonstrating map steady state detection - Register example in Map/index.js for navigation - Restore BugReportExample.js to original state Example features: - Visual status overlay showing event data - Display reason, idle duration, and last gesture type - Console logging for debugging - User hint for interaction 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
is there a way to get MapState onMapSteady? |
|
having an issue with this component on Android: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
onMapIdlehas fundamental issues as an upstream Mapbox SDK concept:LocationPuckcausesonMapIdleto be called infinitely #3801, [Bug]: (Android only) onMapIdle (etc) does not trigger with a native UserLocation #2902)LocationPuckcausesonMapIdleto be called infinitely #3801)Since
onMapIdleis an upstream concept, we cannot fix these issues directly.Solution
Introduces
CameraGestureObserver- a native component that reliably detects when the map reaches a steady state by tracking both camera gestures AND animations.How it works
onMapSteadyevent after a configurable quiet period (default 200ms)Usage
Implementation
Related Issues
Fixes #3801
Fixes #2902
Fixes #3701
🤖 Generated with Claude Code