-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(globe): add auto rotate on initial load
- Loading branch information
1 parent
85047d1
commit 1419e2a
Showing
8 changed files
with
148 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const SET_GLOBE_SPINNING = 'SET_GLOBE_SPINNING'; | ||
|
||
export interface SetGlobeSpinningAction { | ||
type: typeof SET_GLOBE_SPINNING; | ||
spinning: boolean; | ||
} | ||
|
||
const setGlobeSpinningAction = (spinning: boolean): SetGlobeSpinningAction => ({ | ||
type: SET_GLOBE_SPINNING, | ||
spinning | ||
}); | ||
|
||
export default setGlobeSpinningAction; |
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,39 @@ | ||
import { | ||
SET_GLOBE_SPINNING, | ||
SetGlobeSpinningAction | ||
} from '../../actions/set-globe-spinning'; | ||
import { | ||
SET_GLOBE_PROJECTION, | ||
SetGlobeProjectionAction | ||
} from '../../actions/set-globe-projection'; | ||
import {SET_FLY_TO, SetFlyToAction} from '../../actions/set-fly-to'; | ||
|
||
import {GlobeProjection} from '../../types/globe-projection'; | ||
import config from '../../config/main'; | ||
import {parseUrl} from '../../libs/globe-url-parameter'; | ||
|
||
// get initial state from url or fallback to default state in config | ||
console.log(parseUrl()); | ||
|
||
const globeState = parseUrl()?.globeState || config.globe; | ||
const initialState = globeState.spinning; | ||
|
||
console.log(initialState); | ||
|
||
function spinningReducer( | ||
state: boolean = initialState, | ||
action: SetGlobeSpinningAction | SetGlobeProjectionAction | SetFlyToAction | ||
): boolean { | ||
switch (action.type) { | ||
case SET_GLOBE_SPINNING: | ||
return action.spinning; | ||
case SET_GLOBE_PROJECTION: | ||
return action.projection === GlobeProjection.Sphere; | ||
case SET_FLY_TO: | ||
return false; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
export default spinningReducer; |
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,5 @@ | ||
import {State} from '../../reducers/index'; | ||
|
||
export function globeSpinningSelector(state: State): boolean { | ||
return state.globe.spinning; | ||
} |