Clean up formerly commented out code and console logs

This commit is contained in:
Brent Vatne 2018-09-26 10:02:18 -07:00
parent 6e95ceea1f
commit 5002c215ec
3 changed files with 43 additions and 38 deletions

View File

@ -1,6 +1,6 @@
{
"name": "react-navigation-stack",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.5",
"description": "Stack navigator component for React Navigation",
"main": "dist/index.js",
"files": [

View File

@ -12,26 +12,23 @@ export default function createPointerEventsContainer(Component) {
class Container extends React.Component {
constructor(props, context) {
super(props, context);
// this._pointerEvents = this._computePointerEvents();
this._pointerEvents = this._computePointerEvents();
}
componentWillUnmount() {
// this._positionListener && this._positionListener.remove();
this._positionListener && this._positionListener.remove();
}
render() {
// this._bindPosition();
// this._pointerEvents = this._computePointerEvents();
this._bindPosition();
this._pointerEvents = this._computePointerEvents();
const { navigation, scene } = this.props;
return (
<Component
{...this.props}
pointerEvents={
scene.index === navigation.state.index ? 'auto' : 'none'
}
// pointerEvents={this._pointerEvents}
pointerEvents={this._pointerEvents}
onComponentRef={this._onComponentRef}
/>
);
@ -48,41 +45,45 @@ export default function createPointerEventsContainer(Component) {
};
_bindPosition() {
// this._positionListener && this._positionListener.remove();
// this._positionListener = new AnimatedValueSubscription(
// this.props.realPosition,
// () => {}
// );
this._positionListener && this._positionListener.remove();
this._positionListener = new AnimatedValueSubscription(
this.props.realPosition,
this._onPositionChange
);
}
_onPositionChange = ({ value }) => {
// console.log({ value });
// if (this._component) {
// const pointerEvents = this._computePointerEvents();
// if (this._pointerEvents !== pointerEvents) {
// this._pointerEvents = pointerEvents;
// this._component.setNativeProps({ pointerEvents });
// }
// }
// This should log each frame when releasing the gesture or when
// pressing the back button! If not, something has gone wrong with the
// animated value subscription
// console.log(value);
if (this._component) {
const pointerEvents = this._computePointerEvents();
if (this._pointerEvents !== pointerEvents) {
this._pointerEvents = pointerEvents;
this._component.setNativeProps({ pointerEvents });
}
}
};
_computePointerEvents() {
// const { navigation, realPosition, scene } = this.props;
const { navigation, realPosition, scene } = this.props;
// if (scene.isStale || navigation.state.index !== scene.index) {
// // The scene isn't focused.
// return scene.index > navigation.state.index ? 'box-only' : 'none';
// }
if (scene.isStale || navigation.state.index !== scene.index) {
// The scene isn't focused.
return scene.index > navigation.state.index ? 'box-only' : 'none';
}
// const offset = realPosition.__getAnimatedValue() - navigation.state.index;
// if (Math.abs(offset) > MIN_POSITION_OFFSET) {
// // The positon is still away from scene's index.
// // Scene's children should not receive touches until the position
// // is close enough to scene's index.
// return 'box-only';
// }
const offset = realPosition.__getAnimatedValue() - navigation.state.index;
if (Math.abs(offset) > MIN_POSITION_OFFSET) {
// The positon is still away from scene's index.
// Scene's children should not receive touches until the position
// is close enough to scene's index.
return 'box-only';
}
// return 'auto';
return 'auto';
}
}
return Container;

View File

@ -27,9 +27,13 @@ class Transitioner extends React.Component {
const position = new Animated.Value(this.props.navigation.state.index);
this._positionListener = position.addListener(({ value }) => {
// this works until we detach position from a view!
// after that it only updates when we call setValue
console.log(value);
// This should work until we detach position from a view! so we have to be
// careful to not ever detach it, thus the gymnastics in _getPosition in
// StackViewLayout
// This should log each frame when releasing the gesture or when pressing
// the back button! If not, something has gone wrong with the animated
// value subscription
// console.log(value);
});
this.state = {