Fix Main sidebar responder (#1854)
This commit is contained in:
parent
9240bdf642
commit
dca5e85449
3 changed files with 11 additions and 23 deletions
|
|
@ -28,7 +28,7 @@ function makeMapStateToProps() {
|
|||
const teammateNameDisplay = getTeammateNameDisplaySetting(state);
|
||||
const militaryTime = getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time');
|
||||
const enableTimezone = isTimezoneEnabled(state);
|
||||
const userTimezone = enableTimezone && getUserCurrentTimezone(currentUser.timezone);
|
||||
const userTimezone = enableTimezone ? getUserCurrentTimezone(currentUser.timezone) : '';
|
||||
|
||||
return {
|
||||
commentedOnDisplayName: ownProps.commentedOnUserId ? displayUsername(commentedOnUser, teammateNameDisplay) : '',
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ export default class ChannelSidebar extends Component {
|
|||
|
||||
this.state = {
|
||||
show: false,
|
||||
lockMode: 'unlocked',
|
||||
openDrawerOffset,
|
||||
};
|
||||
}
|
||||
|
|
@ -101,7 +102,7 @@ export default class ChannelSidebar extends Component {
|
|||
|
||||
return nextProps.currentTeamId !== currentTeamId ||
|
||||
nextProps.isLandscape !== isLandscape ||
|
||||
nextProps.teamsCount !== teamsCount;
|
||||
nextProps.teamsCount !== teamsCount || this.state.lockMode !== nextState.lockMode;
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
|
@ -230,6 +231,11 @@ export default class ChannelSidebar extends Component {
|
|||
|
||||
onPageSelected = (index) => {
|
||||
this.swiperIndex = index;
|
||||
if (this.swiperIndex === 0) {
|
||||
this.setState({lockMode: 'locked-open'});
|
||||
} else {
|
||||
this.setState({lockMode: 'unlocked'});
|
||||
}
|
||||
};
|
||||
|
||||
onSearchEnds = () => {
|
||||
|
|
@ -338,10 +344,11 @@ export default class ChannelSidebar extends Component {
|
|||
|
||||
render() {
|
||||
const {children, deviceWidth} = this.props;
|
||||
const {openDrawerOffset} = this.state;
|
||||
const {lockMode, openDrawerOffset} = this.state;
|
||||
|
||||
return (
|
||||
<DrawerLayout
|
||||
drawerLockMode={lockMode}
|
||||
ref='drawer'
|
||||
renderNavigationView={this.renderNavigationView}
|
||||
onDrawerClose={this.handleDrawerClose}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import {
|
|||
Platform,
|
||||
StyleSheet,
|
||||
InteractionManager,
|
||||
PanResponder,
|
||||
} from 'react-native';
|
||||
|
||||
export default class Swiper extends PureComponent {
|
||||
|
|
@ -49,20 +48,10 @@ export default class Swiper extends PureComponent {
|
|||
|
||||
this.runOnLayout = true;
|
||||
this.offset = props.width * props.initialPage;
|
||||
this.isScrolling = false;
|
||||
|
||||
this.state = this.initialState(props);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.panResponder = PanResponder.create({
|
||||
onStartShouldSetPanResponder: () => true,
|
||||
onStartShouldSetPanResponderCapture: () => true,
|
||||
onMoveShouldSetPanResponder: () => true,
|
||||
onMoveShouldSetPanResponderCapture: () => true,
|
||||
});
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.width !== nextProps.width) {
|
||||
this.scrollByWidth(nextProps.width);
|
||||
|
|
@ -89,7 +78,6 @@ export default class Swiper extends PureComponent {
|
|||
};
|
||||
|
||||
onScrollBegin = () => {
|
||||
this.isScrolling = true;
|
||||
this.props.onScrollBegin();
|
||||
};
|
||||
|
||||
|
|
@ -99,19 +87,13 @@ export default class Swiper extends PureComponent {
|
|||
e.nativeEvent.contentOffset = {x: e.nativeEvent.position * this.props.width};
|
||||
}
|
||||
|
||||
this.isScrolling = false;
|
||||
|
||||
// get the index
|
||||
this.updateIndex(e.nativeEvent.contentOffset.x);
|
||||
};
|
||||
|
||||
onPageScrollStateChanged = (e) => {
|
||||
switch (e) {
|
||||
case 'idle':
|
||||
this.isScrolling = false;
|
||||
break;
|
||||
case 'dragging':
|
||||
this.isScrolling = true;
|
||||
this.props.onScrollBegin();
|
||||
break;
|
||||
}
|
||||
|
|
@ -152,7 +134,6 @@ export default class Swiper extends PureComponent {
|
|||
if (Platform.OS === 'ios') {
|
||||
return (
|
||||
<ScrollView
|
||||
{...this.panResponder.panHandlers}
|
||||
ref={this.refScrollView}
|
||||
bounces={false}
|
||||
horizontal={true}
|
||||
|
|
@ -227,7 +208,7 @@ export default class Swiper extends PureComponent {
|
|||
};
|
||||
|
||||
scrollToIndex = (index, animated) => {
|
||||
if (this.isScrolling || this.state.total < 2) {
|
||||
if (this.state.total < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue