diff --git a/.gitignore b/.gitignore index 493fb121..ee8bf3fc 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ yarn.lock .vscode/ lib/ .watchmanconfig + +/.history diff --git a/package.json b/package.json index 2d7a11c6..02d5e949 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { - "name": "react-native-modalize", - "version": "2.1.1", + "name": "react-native-modalize-x2", + "version": "2.1.7", "description": "A highly customizable modal/bottom sheet that loves scrolling content.", "main": "lib/index.js", "types": "./lib/index.d.ts", "scripts": { "build": "rm -rf ./lib/* && yarn lint && tsc", - "prepare": "yarn build", + "prepare": "yarn tsc", "lint": "eslint 'src/**/*.ts?(x)' && prettier --list-different \"**/*.{json,md,js,jsx,ts,tsx}\"", "prettier": "prettier --write \"{docs,examples,src}/**/*.{json,md,js,jsx,ts,tsx}\"", "postversion": "sh ./post-version.sh", @@ -60,12 +60,6 @@ "@commitlint/config-conventional" ] }, - "husky": { - "hooks": { - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS", - "pre-commit": "lint-staged" - } - }, "devDependencies": { "@commitlint/cli": "9.1.2", "@commitlint/config-conventional": "9.1.2", diff --git a/src/index.tsx b/src/index.tsx index 68586a5e..54d94ecf 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -112,6 +112,7 @@ const ModalizeBase = ( dragToss = 0.18, threshold = 120, velocity = 2800, + closeVelocity = 250, panGestureAnimatedValue, useNativeDriver = true, @@ -292,8 +293,8 @@ const ModalizeBase = ( easing: timing.easing, useNativeDriver: USE_NATIVE_DRIVER, }), - ]).start(() => { - if (onOpened) { + ]).start(({finished}) => { + if (onOpened && finished) { onOpened(); } @@ -530,12 +531,14 @@ const ModalizeBase = ( handleClose(); } } else { - destSnapPoint = snap; - willCloseModalize = false; + if(cancelTranslateY && toValue > closeVelocity) { + destSnapPoint = snap; + willCloseModalize = false; - if (snap === endHeight) { - willCloseModalize = true; - handleClose(); + if (snap === endHeight) { + willCloseModalize = true; + handleClose(); + } } } } @@ -795,6 +798,7 @@ const ModalizeBase = ( ref={nativeViewChildrenRef} waitFor={tapGestureModalizeRef} simultaneousHandlers={panGestureChildrenRef} + enabled={panGestureEnabled} > {renderContent()} diff --git a/src/options.ts b/src/options.ts index d9a4d964..6f032fe4 100644 --- a/src/options.ts +++ b/src/options.ts @@ -42,6 +42,7 @@ export interface IConfigProps { } export interface IProps { + closeVelocity?: number; /** * A reference to the view (ScrollView, FlatList, SectionList) that provides the scroll behavior, where you will be able to access their owns methods. */