Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(story): set default view for globe #198

Merged
merged 6 commits into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/scripts/components/story/story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,30 @@ const Story: FunctionComponent = () => {
const pageNumber = parseInt(page || '0', 10);
const slide = story && story.slides[pageNumber];
const storyListItem = stories.find(storyItem => storyItem.id === storyId);
const defaultView = {
position: {
height: 14484862,
latitude: 40.659017,
longitude: 0.002816
},
orientation: {
heading: 0,
pitch: -90,
roll: 0
}
};

// fetch story of active storyId
useEffect(() => {
storyId && dispatch(fetchStory(storyId));
}, [dispatch, storyId]);

// fly to position given in a slide
// fly to position given in a slide, if none given set to default
useEffect(() => {
if (slide && slide.flyTo) {
dispatch(setFlyToAction(slide.flyTo));
if (slide) {
dispatch(setFlyToAction(slide.flyTo || defaultView));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [dispatch, slide]);

// redirect to first slide when current slide does not exist
Expand Down
15 changes: 15 additions & 0 deletions src/scripts/selectors/layers/active.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {State} from '../../reducers/index';

export function activeLayersSelector(
state: State,
props: {[key: string]: string} | null
) {
const {mainLayerId, compareLayerId} = props || {};

return {
mainLayerDetails:
(mainLayerId && state.layers.details[mainLayerId]) || null,
compareLayerDetails:
(compareLayerId && state.layers.details[compareLayerId]) || null
};
}