Skip to content

Commit

Permalink
fix: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Guo committed Jul 28, 2020
1 parent 3aa0be7 commit 9e20b9c
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 28 deletions.
6 changes: 1 addition & 5 deletions packages/drawer/src/views/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ const SPRING_CONFIG = {
const ANIMATED_ZERO = new Animated.Value(0);
const ANIMATED_ONE = new Animated.Value(1);

const PROGRESS_EPSILON = 0.05;

type Binary = 0 | 1;

type Renderer = (props: { progress: Animated.Node<number> }) => React.ReactNode;
Expand Down Expand Up @@ -495,9 +493,7 @@ export default class DrawerView extends React.Component<Props> {
// Check if the drawer width is available to avoid division by zero
eq(this.drawerWidth, 0),
0,
Platform.OS === 'windows' || Platform.OS === 'macos'
? max(PROGRESS_EPSILON, abs(divide(this.translateX, this.drawerWidth)))
: abs(divide(this.translateX, this.drawerWidth))
abs(divide(this.translateX, this.drawerWidth))
);

private handleGestureEvent = event([
Expand Down
2 changes: 1 addition & 1 deletion packages/drawer/src/views/GestureHandler.macos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export {
TapGestureHandler,
GestureHandlerRootView,
GestureState,
} from './GestureHandlerCompat';
} from './GestureHandlerStub';
export type { PanGestureHandlerGestureEvent } from 'react-native-gesture-handler';
2 changes: 1 addition & 1 deletion packages/drawer/src/views/GestureHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export {
TapGestureHandler,
GestureHandlerRootView,
GestureState,
} from './GestureHandlerCompat';
} from './GestureHandlerStub';
export type { PanGestureHandlerGestureEvent } from 'react-native-gesture-handler';
2 changes: 1 addition & 1 deletion packages/drawer/src/views/GestureHandler.windows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export {
TapGestureHandler,
GestureHandlerRootView,
GestureState,
} from './GestureHandlerCompat';
} from './GestureHandlerStub';
export type { PanGestureHandlerGestureEvent } from 'react-native-gesture-handler';
9 changes: 8 additions & 1 deletion packages/drawer/src/views/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ const Overlay = React.forwardRef(function Overlay(
) {
const animatedStyle = {
opacity: interpolate(progress, {
inputRange: [PROGRESS_EPSILON, 1],
// Default input range is [PROGRESS_EPSILON, 1]
// On Windows, the output value is 1 when input value is out of range for some reason
// The default value 0 will be interpolated to 1 in this case, which is not what we want.
// Therefore changing input range on Windows to [0,1] instead.
inputRange:
Platform.OS === 'windows' || Platform.OS === 'macos'
? [0, 1]
: [PROGRESS_EPSILON, 1],
outputRange: [0, 1],
}),
// We don't want the user to be able to press through the overlay when drawer is open
Expand Down
2 changes: 1 addition & 1 deletion packages/stack/src/views/GestureHandler.macos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export {
PanGestureHandler,
GestureHandlerRootView,
GestureState,
} from './GestureHandlerCompat';
} from './GestureHandlerStub';
export type { PanGestureHandlerGestureEvent } from 'react-native-gesture-handler';
2 changes: 1 addition & 1 deletion packages/stack/src/views/GestureHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export {
PanGestureHandler,
GestureHandlerRootView,
GestureState,
} from './GestureHandlerCompat';
} from './GestureHandlerStub';
export type { PanGestureHandlerGestureEvent } from 'react-native-gesture-handler';
2 changes: 1 addition & 1 deletion packages/stack/src/views/GestureHandler.windows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export {
PanGestureHandler,
GestureHandlerRootView,
GestureState,
} from './GestureHandlerCompat';
} from './GestureHandlerStub';
export type { PanGestureHandlerGestureEvent } from 'react-native-gesture-handler';
4 changes: 1 addition & 3 deletions packages/stack/src/views/MaskedView.macos.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import StubbedMaskedView from './MaskedView';

export default StubbedMaskedView;
export { default } from './MaskedViewStub';
11 changes: 1 addition & 10 deletions packages/stack/src/views/MaskedView.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
import type * as React from 'react';

type Props = {
maskElement: React.ReactElement;
children: React.ReactElement;
};

export default function MaskedView({ children }: Props) {
return children;
}
export { default } from './MaskedViewStub';
4 changes: 1 addition & 3 deletions packages/stack/src/views/MaskedView.windows.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import StubbedMaskedView from './MaskedView';

export default StubbedMaskedView;
export { default } from './MaskedViewStub';
10 changes: 10 additions & 0 deletions packages/stack/src/views/MaskedViewStub.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type * as React from 'react';

type Props = {
maskElement: React.ReactElement;
children: React.ReactElement;
};

export default function MaskedView({ children }: Props) {
return children;
}

0 comments on commit 9e20b9c

Please sign in to comment.