React Native Navigation Gesture

时间:2016-03-21 06:13:47

标签: ios react-native

我正在使用React Native的Navigator来浏览iOS应用中的场景。我发现尽管我可以通过从左边缘向右边滑动来刷回到上一个屏幕,但是我可以刷的区域看起来不像本机导航那么大或响应。有时我会从边缘滑一点,但它不起作用。

我想知道是否有办法对这个区域进行一些调整,即刷卡后面区域变大一点,这样用户就有更好的成功率。

2 个答案:

答案 0 :(得分:1)

它可能不是最佳解决方案,但您可以在NavigatorSceneConfigs.js中更改edgeHitWidth

“从左到右”的默认值为30

这会影响整个项目,每次升级本机时都需要再次进行这些更改。

答案 1 :(得分:0)

不知道它是否仍然有用,但是:

const SCREEN_WIDTH = require('Dimensions').get('window').width;

const buildStyleInterpolator = require('buildStyleInterpolator');

const BaseSceneConfig = Navigator.SceneConfigs.HorizontalSwipeJump;
const CustomBackGesture = Object.assign({}, BaseSceneConfig.gestures.jumpBack, {
  // Make it so we can drag anywhere on the screen
  edgeHitWidth: SCREEN_WIDTH,

});
const CustomForwardGesture = Object.assign({}, BaseSceneConfig.gestures.jumpForward, {
  // Make it so we can drag anywhere on the screen
  edgeHitWidth: SCREEN_WIDTH,

});
const CustomSceneConfig = Object.assign({}, BaseSceneConfig, {
  // A very tighly wound spring will make this transition fast
  springTension: 100,
  springFriction: 1,
  gestures: {
    jumpBack: CustomBackGesture,
    jumpForward: CustomForwardGesture,
  },
});

你可以自定义手势和edgeHitWidth:SCREEN_WIDTH可以解决问题。