Skip to content

Commit

Permalink
fix: Check if next is title
Browse files Browse the repository at this point in the history
  • Loading branch information
josebui committed Sep 26, 2024
1 parent 45cfaaf commit 1bfbd0e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/storyMap/components/StoryMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,16 @@ const getTransition = ({ config, id, direction }) => {
return {
transition: config.titleTransition,
index: -1,
nextTransition: config.chapters[0],
};
}
const chapterIndex = config.chapters.findIndex(chapter => chapter.id === id);
const chapter = config.chapters[chapterIndex];
const next =
direction === 'up'
? _.get(`chapters[${chapterIndex - 1}]`, config)
: _.get(`chapters[${chapterIndex + 1}]`, config);
const nextIndex = direction === 'up' ? chapterIndex - 1 : chapterIndex + 1;
const nextIsTitle = nextIndex === -1;
const next = nextIsTitle
? config.titleTransition
: _.get(`chapters[${nextIndex}]`, config);
return {
transition: chapter,
nextTransition: next,
Expand Down

0 comments on commit 1bfbd0e

Please sign in to comment.