Last active
July 18, 2019 12:17
-
-
Save jasmo2/4f522d6a6103e67804f0fb4ff5735257 to your computer and use it in GitHub Desktop.
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
import { fromRight, fromBottom } from '../lib/transitions'; | |
const screenVerification = ({ prevScene, nextScene }, prevScreen, nextScreen) => { | |
if ( | |
prevScene && | |
prevScene.route.routeName === prevScreen && | |
nextScene.route.routeName === nextScreen | |
) { | |
return true; | |
} | |
return false; | |
}; | |
const handleCustomTransition = ({ scenes, scene }) => { | |
const prevScene = scenes[scenes.length - 2]; | |
const nextScene = scenes[scenes.length - 1]; | |
const sceneIndex = scene.index; | |
const sceneCount = scenes.length; | |
const sceneConfig = { prevScene, nextScene }; | |
if (sceneIndex >= sceneCount - 1) { | |
if (screenVerification(sceneConfig, 'Screen1', 'Screen2')) { | |
return fromBottom({ duration: 450, percentageRange: 0.05 }); | |
} | |
if (screenVerification(sceneConfig, 'Screen2', 'ScreenNonExistance')) { | |
return fromBottom({ duration: 450, percentageRange: 0.05 }); | |
} | |
} else { | |
if (screenVerification(sceneConfig, 'Screen1', 'Screen2')) { | |
return fromBottom({ duration: 600, percentageRange: 0.05 }); | |
} | |
} | |
return fromRight({}); | |
}; | |
/** | |
* Advance implementation | |
* add the same custom transition to all transition animation | |
*/ | |
export const advanceConfig = nav => handleCustomTransition(nav) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment