From afc7c266d1193fedd2988d8606d5f9b62d2db24d Mon Sep 17 00:00:00 2001 From: Michael Henning Date: Thu, 4 Oct 2018 15:11:40 +0200 Subject: [PATCH 1/5] fix for #22 Signed-off-by: Michael Henning --- Drawer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Drawer/index.js b/Drawer/index.js index bbedf8c..216608e 100644 --- a/Drawer/index.js +++ b/Drawer/index.js @@ -363,7 +363,7 @@ export default class Drawer extends Component { this._mask && this._mask.setNativeProps(this.styles.mask); if (this.props.type === types.Default || dx === 0) { this.styles.main.style.left = dx; - this.styles.main.style.right = -dx; + this.styles.main.style.right = -dx.toFixed(3); this._main && this._main.setNativeProps(this.styles.main); } } From 2b0374726394fc4d6a1863ea04f38a5a795862dd Mon Sep 17 00:00:00 2001 From: Michael Henning Date: Thu, 4 Oct 2018 20:50:50 +0200 Subject: [PATCH 2/5] being even more accurate about rounding Signed-off-by: Michael Henning --- Drawer/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Drawer/index.js b/Drawer/index.js index 216608e..3c5b08f 100644 --- a/Drawer/index.js +++ b/Drawer/index.js @@ -362,8 +362,9 @@ export default class Drawer extends Component { this._rightDrawer && this._rightDrawer.setNativeProps(this.styles.rightDrawer); this._mask && this._mask.setNativeProps(this.styles.mask); if (this.props.type === types.Default || dx === 0) { - this.styles.main.style.left = dx; - this.styles.main.style.right = -dx.toFixed(3); + const val = Math.round( dx * 1e0 ) / 1e0; + this.styles.main.style.left = val; + this.styles.main.style.right = -val; this._main && this._main.setNativeProps(this.styles.main); } } From 0400bac896b5a8fcaccc2e8cbe3c3d427c592b18 Mon Sep 17 00:00:00 2001 From: Michael Henning Date: Wed, 10 Oct 2018 10:47:22 +0200 Subject: [PATCH 3/5] v0.2.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 87fdc61..4a09214 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-drawer-menu", - "version": "0.2.5", + "version": "0.2.6", "scripts": { "start": "react-native start", "ios": "react-native run-ios", From 11323c1d8a1c4b86c7e5c5bc410ab2e2ce72c36d Mon Sep 17 00:00:00 2001 From: Michael Henning Date: Mon, 15 Oct 2018 12:31:20 +0200 Subject: [PATCH 4/5] adding the ability to open/close the drawer from the whole "canvas" Signed-off-by: Michael Henning --- Drawer/index.js | 13 ++++++------- package.json | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Drawer/index.js b/Drawer/index.js index 3c5b08f..65e1852 100644 --- a/Drawer/index.js +++ b/Drawer/index.js @@ -206,7 +206,7 @@ export default class Drawer extends Component { _handlePanResponderEnd (evt, gestureState) { let currentWidth = Math.abs(this._getCurrentDrawerWidth()); let isOpen = this.isLeftOpen || this.isRightOpen; - if (isOpen && gestureState.dx === 0) return this._handleMainBoardPress(); + if (isOpen && gestureState.dx === 0 && (gestureState.x0 < this.MAX_DX * 0.2)) return this._handleMainBoardPress(); if (currentWidth === this.MAX_DX) return this._drawerDidOpen(); if (currentWidth === 0) return this._drawerDidClose(); if (currentWidth > this.MAX_DX / 2) { @@ -231,18 +231,18 @@ export default class Drawer extends Component { if (Math.abs(dx) < Math.abs(dy)) return false; // swipe when drawer is fully opened if ( - this.isLeftOpen && !leftDisabled && dx < 0 || - (this.isRightOpen && !rightDisabled && dx > 0) + this.isLeftOpen && !leftDisabled && dx < 10 || + (this.isRightOpen && !rightDisabled && dx > 10) ) { return true; } // swipe right to open left drawer - if (!leftDisabled && this.isLeft && x0 <= width * 0.2 && !isOpen && dx > 0) { + if (!leftDisabled && this.isLeft && x0 <= width * 0.2 && !isOpen && dx > 10) { this.isLeftActive = true; return true; } // swipe left to open right drawer - if (!rightDisabled && this.isRight && x0 >= this.MAX_DX && !isOpen && dx < 0) { + if (!rightDisabled && this.isRight && x0 >= width * 0.2 && !isOpen && dx < 10) { this.isRightActive = true; return true; } @@ -395,11 +395,10 @@ export default class Drawer extends Component { let leftDrawerContent = this.props.leftDrawerContent ? this._bindDrawerRef(this.props.leftDrawerContent) : null; let rightDrawerContent = this.props.rightDrawerContent ? this._bindDrawerRef(this.props.rightDrawerContent) : null; return ( - + {this.props.children} {this.state.showMask && Date: Thu, 18 Oct 2018 09:42:32 +0200 Subject: [PATCH 5/5] make me insensitive Signed-off-by: Michael Henning --- Drawer/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Drawer/index.js b/Drawer/index.js index 65e1852..49e76c3 100644 --- a/Drawer/index.js +++ b/Drawer/index.js @@ -231,7 +231,7 @@ export default class Drawer extends Component { if (Math.abs(dx) < Math.abs(dy)) return false; // swipe when drawer is fully opened if ( - this.isLeftOpen && !leftDisabled && dx < 10 || + this.isLeftOpen && !leftDisabled && dx < -10 || (this.isRightOpen && !rightDisabled && dx > 10) ) { return true; @@ -242,7 +242,7 @@ export default class Drawer extends Component { return true; } // swipe left to open right drawer - if (!rightDisabled && this.isRight && x0 >= width * 0.2 && !isOpen && dx < 10) { + if (!rightDisabled && this.isRight && x0 >= width * 0.2 && !isOpen && dx < -10) { this.isRightActive = true; return true; }