diff --git a/src/scripts/components/story/story.tsx b/src/scripts/components/story/story.tsx index c1c428992..b8b737c32 100644 --- a/src/scripts/components/story/story.tsx +++ b/src/scripts/components/story/story.tsx @@ -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 diff --git a/src/scripts/selectors/layers/active.ts b/src/scripts/selectors/layers/active.ts new file mode 100644 index 000000000..19bf61046 --- /dev/null +++ b/src/scripts/selectors/layers/active.ts @@ -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 + }; +}