Removed animation completely

This commit is contained in:
Gytis Vinclovas 2018-03-23 22:57:22 +02:00
parent f68987441f
commit 16ee33ab24
2 changed files with 11 additions and 54 deletions

View File

@ -2,16 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { ifIphoneX } from 'react-native-iphone-x-helper'; import { ifIphoneX } from 'react-native-iphone-x-helper';
import { import { Dimensions, View, TouchableWithoutFeedback, Image, Text, StatusBar } from 'react-native';
Animated,
Dimensions,
Easing,
View,
TouchableWithoutFeedback,
Image,
Text,
StatusBar,
} from 'react-native';
import style from './style'; import style from './style';
import StoryListView from '../StoryListView'; import StoryListView from '../StoryListView';
import StoryView from '../StoryView'; import StoryView from '../StoryView';
@ -34,7 +25,6 @@ export default class OnDeviceUI extends Component {
super(...args); super(...args);
this.state = { this.state = {
menuAnimation: new Animated.Value(0),
isMenuOpen: false, isMenuOpen: false,
selectedKind: null, selectedKind: null,
selectedStory: null, selectedStory: null,
@ -71,24 +61,14 @@ export default class OnDeviceUI extends Component {
}; };
handleToggleMenu = () => { handleToggleMenu = () => {
const isMenuOpen = !this.state.isMenuOpen;
if (this.props.animated) {
Animated.timing(this.state.menuAnimation, {
toValue: isMenuOpen ? 1 : 0,
duration: 150,
easing: Easing.linear,
}).start();
}
this.setState({ this.setState({
isMenuOpen, isMenuOpen: !this.state.isMenuOpen,
}); });
}; };
render() { render() {
const { stories, animated, events, url } = this.props; const { stories, events, url } = this.props;
const { isPortrait, isMenuOpen, menuAnimation, selectedKind, selectedStory } = this.state; const { isPortrait, isMenuOpen, selectedKind, selectedStory } = this.state;
const iPhoneXStyles = ifIphoneX( const iPhoneXStyles = ifIphoneX(
isPortrait isPortrait
@ -101,23 +81,12 @@ export default class OnDeviceUI extends Component {
{} {}
); );
let translateX;
if (animated) {
translateX = menuAnimation.interpolate({
inputRange: [0, 1],
outputRange: [-DRAWER_WIDTH - 30, 0],
});
} else {
translateX = isMenuOpen ? 0 : -DRAWER_WIDTH - 30;
}
const menuStyles = [ const menuStyles = [
style.menuContainer, style.menuContainer,
{ {
transform: [ transform: [
{ {
translateX, translateX: isMenuOpen ? 0 : -DRAWER_WIDTH - 30,
}, },
], ],
}, },
@ -127,12 +96,7 @@ export default class OnDeviceUI extends Component {
const headerStyles = [ const headerStyles = [
style.headerContainer, style.headerContainer,
{ {
opacity: animated opacity: +!isMenuOpen,
? menuAnimation.interpolate({
inputRange: [0, 1],
outputRange: [1, 0],
})
: +!isMenuOpen,
}, },
]; ];
@ -156,7 +120,7 @@ export default class OnDeviceUI extends Component {
return ( return (
<View style={style.main}> <View style={style.main}>
<View style={previewContainerStyles}> <View style={previewContainerStyles}>
<Animated.View style={headerStyles}> <View style={headerStyles}>
<TouchableWithoutFeedback <TouchableWithoutFeedback
onPress={this.handleToggleMenu} onPress={this.handleToggleMenu}
testID="Storybook.OnDeviceUI.open" testID="Storybook.OnDeviceUI.open"
@ -169,14 +133,14 @@ export default class OnDeviceUI extends Component {
<Text style={style.headerText} numberOfLines={1}> <Text style={style.headerText} numberOfLines={1}>
{selectedKind} {selectedStory} {selectedKind} {selectedStory}
</Text> </Text>
</Animated.View> </View>
<View style={previewWrapperStyles}> <View style={previewWrapperStyles}>
<View style={style.preview}> <View style={style.preview}>
<StoryView url={url} events={events} /> <StoryView url={url} events={events} />
</View> </View>
</View> </View>
</View> </View>
<Animated.View style={menuStyles}> <View style={menuStyles}>
<TouchableWithoutFeedback <TouchableWithoutFeedback
onPress={this.handleToggleMenu} onPress={this.handleToggleMenu}
testID="Storybook.OnDeviceUI.close" testID="Storybook.OnDeviceUI.close"
@ -193,7 +157,7 @@ export default class OnDeviceUI extends Component {
selectedKind={selectedKind} selectedKind={selectedKind}
selectedStory={selectedStory} selectedStory={selectedStory}
/> />
</Animated.View> </View>
</View> </View>
); );
} }
@ -212,10 +176,8 @@ OnDeviceUI.propTypes = {
removeListener: PropTypes.func.isRequired, removeListener: PropTypes.func.isRequired,
}).isRequired, }).isRequired,
url: PropTypes.string, url: PropTypes.string,
animated: PropTypes.bool,
}; };
OnDeviceUI.defaultProps = { OnDeviceUI.defaultProps = {
url: '', url: '',
animated: true,
}; };

View File

@ -74,12 +74,7 @@ export default class Preview {
// finally return the preview component // finally return the preview component
return params.onDeviceUI return params.onDeviceUI
? <OnDeviceUI ? <OnDeviceUI stories={this._stories} events={this._events} url={webUrl} />
stories={this._stories}
events={this._events}
url={webUrl}
animated={params.onDeviceUIAnimated}
/>
: <StoryView url={webUrl} events={this._events} />; : <StoryView url={webUrl} events={this._events} />;
}; };
} }