RTL support with native driver
This commit is contained in:
parent
385f48831b
commit
cd56d08793
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import Expo from 'expo';
|
||||
import { FlatList } from 'react-native';
|
||||
import { FlatList, I18nManager } from 'react-native';
|
||||
import { createSwitchNavigator } from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { ListSection, Divider } from 'react-native-paper';
|
||||
|
@ -10,8 +10,12 @@ import TransparentStack from './src/TransparentStack';
|
|||
import ModalStack from './src/ModalStack';
|
||||
import GestureInteraction from './src/GestureInteraction';
|
||||
|
||||
// Uncomment the following line to force RTL. Requires closing and re-opening
|
||||
// your app after you first load it with this option enabled.
|
||||
// I18nManager.forceRTL(false);
|
||||
|
||||
// Comment the following two lines to stop using react-native-screens
|
||||
import { useScreens } from 'react-native-screens';
|
||||
// import { useScreens } from 'react-native-screens';
|
||||
// useScreens();
|
||||
|
||||
const data = [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "react-navigation-stack",
|
||||
"version": "1.0.0-alpha.5",
|
||||
"version": "1.0.0-alpha.8",
|
||||
"description": "Stack navigator component for React Navigation",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
|
|
|
@ -415,6 +415,21 @@ class StackViewLayout extends React.Component {
|
|||
_handleActivateGestureHorizontal = nativeEvent => {
|
||||
let { index } = this.props.transitionProps.navigation.state;
|
||||
|
||||
if (this._isMotionInverted()) {
|
||||
this.setState({
|
||||
gesturePosition: Animated.add(
|
||||
index,
|
||||
Animated.divide(
|
||||
this.gestureX,
|
||||
this.props.transitionProps.layout.width
|
||||
)
|
||||
).interpolate({
|
||||
inputRange: [index - 1, index],
|
||||
outputRange: [index - 1, index],
|
||||
extrapolate: 'clamp',
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
gesturePosition: Animated.add(
|
||||
index,
|
||||
|
@ -431,6 +446,7 @@ class StackViewLayout extends React.Component {
|
|||
extrapolate: 'clamp',
|
||||
}),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_handleActivateGestureVertical = nativeEvent => {
|
||||
|
@ -518,8 +534,8 @@ class StackViewLayout extends React.Component {
|
|||
|
||||
// Calculate animate duration according to gesture speed and moved distance
|
||||
const distance = layout.height.__getValue();
|
||||
const movedDistance = nativeEvent.translationX;
|
||||
const gestureVelocity = nativeEvent.velocityX;
|
||||
const movedDistance = nativeEvent.translationY;
|
||||
const gestureVelocity = nativeEvent.velocityY;
|
||||
const defaultVelocity = distance / ANIMATION_DURATION;
|
||||
const velocity = Math.max(Math.abs(gestureVelocity), defaultVelocity);
|
||||
const resetDuration = movedDistance / velocity;
|
||||
|
|
Loading…
Reference in New Issue