Skip to content

Instantly share code, notes, and snippets.

@jasmo2
Last active July 18, 2019 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasmo2/4f522d6a6103e67804f0fb4ff5735257 to your computer and use it in GitHub Desktop.
Save jasmo2/4f522d6a6103e67804f0fb4ff5735257 to your computer and use it in GitHub Desktop.
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