-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more hooks and improve isolation of kepler.gl within components (#88
) * Add more hooks and improve isolation of kepler within components - Remove kepler state selectors from within Stage component. - Create hooks for kepler keyframes and frame preparation. - Add deckProps and staticMapProps override - TODO: Remove kepler state selectors StageMap and StageContainer too. - TODO: timeline reducer contains kepler-specific keyframe state. Looking to be more flexible.
- Loading branch information
1 parent
8eabc09
commit 197920d
Showing
7 changed files
with
149 additions
and
116 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {useCallback} from 'react'; | ||
import {useDispatch, useSelector} from 'react-redux'; | ||
import {CameraKeyframes} from '@hubble.gl/core'; | ||
|
||
import {cameraKeyframeSelector} from './timelineSlice'; | ||
import {dimensionSelector} from '../renderer'; | ||
import {updateViewState} from '../stage/mapSlice'; | ||
|
||
export function useCameraKeyframes() { | ||
const cameraKeyframe = useSelector(cameraKeyframeSelector); | ||
const dimension = useSelector(dimensionSelector); | ||
const getCameraKeyframes = useCallback(() => { | ||
const camera = new CameraKeyframes({ | ||
...cameraKeyframe, | ||
width: dimension.width, | ||
height: dimension.height | ||
}); | ||
return camera; | ||
}, [cameraKeyframe]); | ||
|
||
return getCameraKeyframes; | ||
} | ||
|
||
export function usePrepareCameraFrame() { | ||
const dispatch = useDispatch(); | ||
const prepareFrame = useCallback(scene => { | ||
dispatch(updateViewState(scene.keyframes.camera.getFrame())); | ||
}); | ||
return prepareFrame; | ||
} |