Как изменить интерполяцию жестов с оси x на ось y в экране React NavigationInterpolator - PullRequest
1 голос
/ 21 марта 2019

Я столкнулся с проблемой, когда я хотел бы, чтобы пользователь мог двигать пальцем вниз по оси Y, и экран будет падать вместе с ним, но, к сожалению, прямо сейчас, если пользователь скользит по оси X-. По оси (слева направо) экран будет интерполировать это по оси Y.

Вот гиф проблемы: https://imgur.com/FKG5Cax

export const ExchangeNavigator = createStackNavigator(
  {
    addExchange: { screen: AddExchangeScreen },
    addCoinbase: { screen: AddCoinbaseScreen },
    addBinance: { screen: AddBinanceScreen },
  },
  {
    navigationOptions: {
      header: null,
      gesturesEnabled: true,
    },
    transitionConfig: TransitionConfiguration,
  },
)

export default ExchangeNavigator


export const SlideToTopTransition = (index, position) => {
  const inputRange = [index - 1, index, index + 0.99, index + 1]

  const translateY = position.interpolate({
    inputRange,
    outputRange: [DEVICE_RESOLUTION.height, 0, 0, 0],
  })

  return { transform: [{ translateY }] }
}

export const TransitionConfiguration = () => {
  return {
    transitionSpec: {
      useNativeDriver: true
    },
    // Define scene interpolation, eq. custom transition
    screenInterpolator: sceneProps => {
      const { position, scene } = sceneProps
      const { index, route } = scene
      const params = route.params || {}
      const transition = params.transition || 'default'

      return {
        slideToTop: SlideToTopTransition(index, position),
        slideToRight: SlideToRightTransition(index, position),
        slideToLeft: SlideToLeftTransition(index, position),
        modalTransition: ModalTransition(index, position),
        fadeTransition: FadeTransition(index, position),
        default: SlideToTopTransition(index, position),
      }[transition]
    },
  }
}

export default TransitionConfiguration

Каков наилучший способ изменить пользовательский жест слева направо -> сверху вниз и, соответственно, интерполировать по оси у?

Спасибо за ваше время !!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...