Skip to content

Commit

Permalink
Fix outro fly
Browse files Browse the repository at this point in the history
  • Loading branch information
barbara-chaves committed Nov 30, 2023
1 parent fcb8122 commit 4a663f2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
10 changes: 7 additions & 3 deletions client/src/containers/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
layersInteractiveIdsAtom,
// popupAtom,
tmpBboxAtom,
isFlyingBackAtom,
} from '@/store';

// import { useGetLayers } from '@/types/generated/layer';
Expand Down Expand Up @@ -78,16 +79,19 @@ export default function MapContainer() {

const bbox = useRecoilValue(bboxAtom);
const tmpBbox = useRecoilValue(tmpBboxAtom);
// const layersInteractive = useRecoilValue(layersInteractiveAtom);
const isFlyingBack = useRecoilValue(isFlyingBackAtom);

const layersInteractiveIds = useRecoilValue(layersInteractiveIdsAtom);

const setBbox = useSetRecoilState(bboxAtom);
const setTmpBbox = useSetRecoilState(tmpBboxAtom);
// const setPopup = useSetRecoilState(popupAtom);

const pathname = usePathname();

const isHomePage = useMemo(() => !pathname.includes('stories'), [pathname]);
const isHomePage = useMemo(
() => !pathname.includes('stories') && !isFlyingBack,
[pathname, isFlyingBack]
);

// const { data: layersInteractiveData } = useGetLayers(
// {
Expand Down
15 changes: 11 additions & 4 deletions client/src/containers/story/steps/layouts/outro-step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { useRouter } from 'next/navigation';

import { useScroll, motion, useTransform } from 'framer-motion';
import { useResetRecoilState } from 'recoil';
import { useSetRecoilState } from 'recoil';

import env from '@/env.mjs';

import { tmpBboxAtom } from '@/store';
import { isFlyingBackAtom, layersAtom } from '@/store';

import { StepLayoutItem, StepLayoutOutroStepComponent } from '@/types/generated/strapi.schemas';

Expand All @@ -23,8 +23,9 @@ type MediaStepLayoutProps = {

const OutroStepLayout = ({ step, showContent }: MediaStepLayoutProps) => {
const { push } = useRouter();
const setLayers = useSetRecoilState(layersAtom);

const resetBbox = useResetRecoilState(tmpBboxAtom);
const setIsFlyingBack = useSetRecoilState(isFlyingBackAtom);

const { content, title } = step as StepLayoutOutroStepComponent;
const containerRef = useRef<HTMLDivElement>(null);
Expand All @@ -44,12 +45,18 @@ const OutroStepLayout = ({ step, showContent }: MediaStepLayoutProps) => {
});

useEffect(() => {
// TEMPORARY FIX
setLayers([5]);

if (!showContent) setShow(false);
}, [showContent]);

useTransform(scrollYProgress, (v) => {
if (v > 0.6) {
resetBbox();
setIsFlyingBack(true);
setTimeout(() => {
setIsFlyingBack(false);
}, 3000);
push('/');
}
});
Expand Down
5 changes: 5 additions & 0 deletions client/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export const markerAtom = atom<MapboxGeoJSONFeature | null>({
default: null,
});

export const isFlyingBackAtom = atom<boolean>({
key: 'is-flying-back',
default: false,
});

export const DEFAULT_SETTINGS = {
expand: true,
};
Expand Down
1 change: 1 addition & 0 deletions cms/src/plugins/map-field/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@strapi/typescript-utils": "4.11.2",
"@types/react": "^17.0.53",
"@types/react-dom": "^18.0.28",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.26",
"react-dom": "^18.2.0",
Expand Down
3 changes: 2 additions & 1 deletion cms/src/plugins/map-field/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ __metadata:
languageName: node
linkType: hard

"@types/react-router@npm:*":
"@types/react-router@npm:*, @types/react-router@npm:^5.1.20":
version: 5.1.20
resolution: "@types/react-router@npm:5.1.20"
dependencies:
Expand Down Expand Up @@ -2475,6 +2475,7 @@ __metadata:
"@strapi/typescript-utils": 4.11.2
"@types/react": ^17.0.53
"@types/react-dom": ^18.0.28
"@types/react-router": ^5.1.20
"@types/react-router-dom": ^5.3.3
"@types/styled-components": ^5.1.26
mapbox-gl: 2.15.0
Expand Down

0 comments on commit 4a663f2

Please sign in to comment.