Skip to content

Commit 7c73191

Browse files
adding sensitivity to swipe and fixes on ios
1 parent 74e128e commit 7c73191

File tree

7 files changed

+69
-65
lines changed

7 files changed

+69
-65
lines changed

example/ios/AwesomeProject.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@
659659
DEVELOPMENT_TEAM = YT5JKQN5YD;
660660
ENABLE_BITCODE = NO;
661661
INFOPLIST_FILE = AwesomeProject/Info.plist;
662+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
662663
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
663664
OTHER_LDFLAGS = (
664665
"$(inherited)",
@@ -682,6 +683,7 @@
682683
CURRENT_PROJECT_VERSION = 1;
683684
DEVELOPMENT_TEAM = YT5JKQN5YD;
684685
INFOPLIST_FILE = AwesomeProject/Info.plist;
686+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
685687
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
686688
OTHER_LDFLAGS = (
687689
"$(inherited)",

example/ios/AwesomeProject.xcodeproj/xcshareddata/xcschemes/AwesomeProject.xcscheme

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
</Testables>
4242
</TestAction>
4343
<LaunchAction
44-
buildConfiguration = "Debug"
45-
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
46-
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
44+
buildConfiguration = "Release"
45+
selectedDebuggerIdentifier = ""
46+
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
4747
launchStyle = "0"
4848
useCustomWorkingDirectory = "NO"
4949
ignoresPersistentStateOnLaunch = "NO"

lib/RNNDrawer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var __extends = (this && this.__extends) || (function () {
77
var extendStatics = function (d, b) {
88
extendStatics = Object.setPrototypeOf ||
99
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
10+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1111
return extendStatics(d, b);
1212
};
1313
return function (d, b) {
@@ -68,7 +68,10 @@ var RNNDrawer = /** @class */ (function () {
6868
_this.panResponder = react_native_1.PanResponder.create({
6969
onStartShouldSetPanResponder: function (_evt, _gestureState) { return false; },
7070
onStartShouldSetPanResponderCapture: function (_evt, _gestureState) { return false; },
71-
onMoveShouldSetPanResponder: function (_evt, _gestureState) { return true; },
71+
onMoveShouldSetPanResponder: function (_evt, _gestureState) {
72+
var dx = _gestureState.dx;
73+
return Math.abs(dx) > 5;
74+
},
7275
onMoveShouldSetPanResponderCapture: function (_evt, _gestureState) { return false; },
7376
onPanResponderGrant: function (_evt, _gestureState) {
7477
events_1.dispatch('SWIPE_START');
@@ -222,9 +225,6 @@ var RNNDrawer = /** @class */ (function () {
222225
var openedPercentage = Math.abs((Math.abs(alignedMovementValue) / _this.drawerWidth) * 100 - 100);
223226
// Calculates the opacity to set of the screen based on the percentage the drawer is open
224227
var normalizedOpacity = Math.min(openedPercentage / 100, fadeOpacity);
225-
console.log({
226-
alignedMovementValue: alignedMovementValue, normalizedOpacity: normalizedOpacity
227-
});
228228
// Does allow the drawer to go further than the maximum width
229229
if (_this.drawerOpenedValues[direction] > alignedMovementValue) {
230230
// Sets the animation values, we use this so we can resume animation from any point

lib/SideMenuView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var __extends = (this && this.__extends) || (function () {
88
var extendStatics = function (d, b) {
99
extendStatics = Object.setPrototypeOf ||
1010
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
11+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1212
return extendStatics(d, b);
1313
};
1414
return function (d, b) {

lib/events.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* @description Event dispatcher for comunication between components.
55
*/
66
Object.defineProperty(exports, "__esModule", { value: true });
7-
exports.dispatch = exports.listen = void 0;
87
/**
98
* @description events
109
* @private

lib/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.SideMenuView = exports.RNNDrawer = void 0;
43
var RNNDrawer_1 = require("./RNNDrawer");
5-
Object.defineProperty(exports, "RNNDrawer", { enumerable: true, get: function () { return RNNDrawer_1.default; } });
4+
exports.RNNDrawer = RNNDrawer_1.default;
65
var SideMenuView_1 = require("./SideMenuView");
7-
Object.defineProperty(exports, "SideMenuView", { enumerable: true, get: function () { return SideMenuView_1.default; } });
6+
exports.SideMenuView = SideMenuView_1.default;

src/RNNDrawer.tsx

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,50 +25,50 @@ import { listen, dispatch } from './events';
2525
const MaxWidthOnLandscapeMode = 300;
2626

2727
declare interface RNNDrawerOptions {
28-
/**
29-
* Id of parent component of the drawer.
30-
* This field is necessary in order to be able
31-
* to push screens inside the drawer
32-
*/
33-
parentComponentId: string;
34-
35-
/**
36-
* Direction to open the collage,
37-
* one of: ["left", "right", "top", "bottom"]
38-
* If not provided, drawer might have
39-
* a weird effect when closing
40-
*/
41-
direction: DirectionType;
42-
43-
/**
44-
* Time in milliseconds to execute the drawer opening animation
45-
*/
46-
animationOpenTime?: number;
47-
48-
/**
49-
* Time in milliseconds to execute the drawer closing animation
50-
*/
51-
animationCloseTime?: number;
52-
53-
/**
54-
* Whether the drawer be dismissed when a click is registered outside
55-
*/
56-
dismissWhenTouchOutside?: boolean;
57-
58-
/**
59-
* Opacity of the screen outside the drawer
60-
*/
61-
fadeOpacity?: number;
62-
63-
/**
64-
* Width of drawer in relation to the screen (0 to 1)
65-
*/
66-
drawerScreenWidth?: number;
67-
68-
/**
69-
* Height of drawer in relation to the screen (0 to 1)
70-
*/
71-
drawerScreenHeight?: number;
28+
/**
29+
* Id of parent component of the drawer.
30+
* This field is necessary in order to be able
31+
* to push screens inside the drawer
32+
*/
33+
parentComponentId: string;
34+
35+
/**
36+
* Direction to open the collage,
37+
* one of: ["left", "right", "top", "bottom"]
38+
* If not provided, drawer might have
39+
* a weird effect when closing
40+
*/
41+
direction: DirectionType;
42+
43+
/**
44+
* Time in milliseconds to execute the drawer opening animation
45+
*/
46+
animationOpenTime?: number;
47+
48+
/**
49+
* Time in milliseconds to execute the drawer closing animation
50+
*/
51+
animationCloseTime?: number;
52+
53+
/**
54+
* Whether the drawer be dismissed when a click is registered outside
55+
*/
56+
dismissWhenTouchOutside?: boolean;
57+
58+
/**
59+
* Opacity of the screen outside the drawer
60+
*/
61+
fadeOpacity?: number;
62+
63+
/**
64+
* Width of drawer in relation to the screen (0 to 1)
65+
*/
66+
drawerScreenWidth?: number;
67+
68+
/**
69+
* Height of drawer in relation to the screen (0 to 1)
70+
*/
71+
drawerScreenHeight?: number;
7272
}
7373

7474

@@ -130,12 +130,12 @@ interface SwipeMoveInterface {
130130
}
131131

132132
class RNNDrawer {
133-
/**
134-
* Generates the drawer component to
135-
* be used with react-native-navigation
136-
*
137-
* @param component
138-
*/
133+
/**
134+
* Generates the drawer component to
135+
* be used with react-native-navigation
136+
*
137+
* @param component
138+
*/
139139
static create(Component: React.ComponentType): any {
140140
class WrappedDrawer extends React.Component<IProps, IState> {
141141
private readonly screenWidth: number;
@@ -186,7 +186,11 @@ class RNNDrawer {
186186
onMoveShouldSetPanResponder: (
187187
_evt: GestureResponderEvent,
188188
_gestureState: PanResponderGestureState,
189-
) => true,
189+
) => {
190+
const { dx } = _gestureState;
191+
192+
return Math.abs(dx) > 5;
193+
},
190194
onMoveShouldSetPanResponderCapture: (
191195
_evt: GestureResponderEvent,
192196
_gestureState: PanResponderGestureState,
@@ -373,7 +377,7 @@ class RNNDrawer {
373377
if (this.props.direction === "right") {
374378
// Calculates the position of the drawer from the left side of the screen
375379
const alignedMovementValue = window.width - this.drawerWidth;
376-
380+
377381
this.state.sideMenuOpenValue.setValue(alignedMovementValue);
378382
}
379383
})

0 commit comments

Comments
 (0)