Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

add overlay animation

ammarahm-ed057e399c9365
diff --git a/apps/mobile/src/components/SideMenu/index.js b/apps/mobile/src/components/SideMenu/index.js
index 619251e23..597500cc9 100644
--- a/apps/mobile/src/components/SideMenu/index.js
+++ b/apps/mobile/src/components/SideMenu/index.js
@@ -26,7 +26,7 @@ export default class SideMenu extends React.Component {
this.prevLeft = 0;
this.isOpen = !!props.isOpen;
this.isGestureEnabled = true;
-
+ this.overlay;
this.opacity = new Animated.Value(0);
const initialMenuPositionMultiplier =
@@ -103,14 +103,26 @@ export default class SideMenu extends React.Component {
* @return {React.Component}
*/
getContentView() {
- let overlay = null;
+ //let overlay = null;
+
+ const {width, height} = this.state;
+ const ref = sideMenu => (this.sideMenu = sideMenu);
+ const style = [
+ styles.frontView,
+ {width, height},
+ this.props.animationStyle(this.state.left),
+ ];
+
+ return (
+ <Animated.View style={style} ref={ref} {...this.responder.panHandlers}>
+ {this.props.children}
- if (this.isOpen) {
- overlay = (
<TouchableWithoutFeedback onPress={() => this.openMenu(false)}>
<Animated.View
+ ref={ref => (this.overlay = ref)}
style={{
- position: 'absolute',
+ display: 'none',
+ position: 'relative',
top: 0,
left: 0,
bottom: 0,
@@ -120,31 +132,33 @@ export default class SideMenu extends React.Component {
}}
/>
</TouchableWithoutFeedback>
- );
- }
-
- const {width, height} = this.state;
- const ref = sideMenu => (this.sideMenu = sideMenu);
- const style = [
- styles.frontView,
- {width, height},
- this.props.animationStyle(this.state.left),
- ];
-
- return (
- <Animated.View style={style} ref={ref} {...this.responder.panHandlers}>
- {this.props.children}
- {overlay}
</Animated.View>
);
}
changeOpacity(opacity) {
+ if (opacity === 0.5) {
+ this.overlay.setNativeProps({
+ style: {
+ display: 'flex',
+ position: 'absolute',
+ },
+ });
+ }
Animated.timing(this.opacity, {
toValue: opacity,
duration: 400,
useNativeDriver: true,
- }).start();
+ }).start(() => {
+ if (opacity === 0) {
+ this.overlay.setNativeProps({
+ style: {
+ display: 'none',
+ position: 'relative',
+ },
+ });
+ }
+ });
}
moveLeft(offset) {
@@ -170,6 +184,9 @@ export default class SideMenu extends React.Component {
newLeft = this.menuPositionMultiplier() * this.state.openMenuOffset;
}
+ let o = newLeft / this.props.openMenuOffset;
+ this.opacity.setValue(o * 0.5);
+
this.props.onMove(newLeft);
this.state.left.setValue(newLeft);
}
@@ -193,7 +210,12 @@ export default class SideMenu extends React.Component {
if (this.isOpen) {
return touchMoved;
}
-
+ this.overlay.setNativeProps({
+ style: {
+ display: 'flex',
+ position: 'absolute',
+ },
+ });
const withinEdgeHitWidth =
this.props.menuPosition === 'right'
? gestureState.moveX > deviceScreen.width - this.props.edgeHitWidth
@@ -208,7 +230,7 @@ export default class SideMenu extends React.Component {
openMenu(isOpen) {
const {hiddenMenuOffset, openMenuOffset} = this.state;
- this.changeOpacity(isOpen ? 0.4 : 0);
+ this.changeOpacity(isOpen ? 0.5 : 0);
this.moveLeft(isOpen ? openMenuOffset : hiddenMenuOffset);
this.isOpen = isOpen;