react-native-swipeable-actions 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -3
- package/android/build.gradle +6 -2
- package/android/src/main/java/expo/modules/swipeable/SwipeableView.kt +2 -20
- package/build/SwipeableActions.js +2 -2
- package/build/SwipeableActions.js.map +1 -1
- package/build/SwipeableView.js +1 -0
- package/build/SwipeableView.js.map +1 -1
- package/build/index.d.ts +0 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -5
- package/build/index.js.map +1 -1
- package/jestSetup.js +44 -0
- package/package.json +3 -3
- package/src/SwipeableActions.tsx +2 -2
- package/src/SwipeableView.tsx +2 -0
- package/src/index.ts +0 -4
- package/build/swipeStateUtils.d.ts +0 -16
- package/build/swipeStateUtils.d.ts.map +0 -1
- package/build/swipeStateUtils.js +0 -37
- package/build/swipeStateUtils.js.map +0 -1
- package/src/swipeStateUtils.ts +0 -55
package/README.md
CHANGED
|
@@ -21,9 +21,16 @@ Benchmark comparison on Android 16, Pixel 8 Pro, GrapheneOS — List Demo with 1
|
|
|
21
21
|
<th>react-native-swipeable-actions</th>
|
|
22
22
|
</tr>
|
|
23
23
|
<tr>
|
|
24
|
-
<td
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
<td>
|
|
25
|
+
|
|
26
|
+
https://github.com/user-attachments/assets/6d7cf1e6-c719-4044-8b47-205e94a38d10
|
|
27
|
+
|
|
28
|
+
</td>
|
|
29
|
+
<td>
|
|
30
|
+
|
|
31
|
+
https://github.com/user-attachments/assets/f59ef788-caf4-4985-93bc-8d098122fe1a
|
|
32
|
+
|
|
33
|
+
</td></tr>
|
|
27
34
|
<tr>
|
|
28
35
|
<td align="center">Reanimated</td>
|
|
29
36
|
<td align="center">Pure native</td>
|
|
@@ -34,6 +41,8 @@ Benchmark comparison on Android 16, Pixel 8 Pro, GrapheneOS — List Demo with 1
|
|
|
34
41
|
</tr>
|
|
35
42
|
</table>
|
|
36
43
|
|
|
44
|
+
> Videos not loading? View on [GitHub](https://github.com/chocky335/react-native-swipeable-actions#performance)
|
|
45
|
+
|
|
37
46
|
## Installation
|
|
38
47
|
|
|
39
48
|
```bash
|
|
@@ -245,6 +254,15 @@ import {
|
|
|
245
254
|
} from 'react-native-swipeable-actions'
|
|
246
255
|
```
|
|
247
256
|
|
|
257
|
+
## Testing
|
|
258
|
+
|
|
259
|
+
Jest mock is included for testing components that use Swipeable:
|
|
260
|
+
|
|
261
|
+
```js
|
|
262
|
+
// jest.config.js
|
|
263
|
+
import 'react-native-swipeable-actions/jestSetup.js'
|
|
264
|
+
```
|
|
265
|
+
|
|
248
266
|
## License
|
|
249
267
|
|
|
250
268
|
MIT
|
package/android/build.gradle
CHANGED
|
@@ -2,8 +2,11 @@ apply plugin: 'com.android.library'
|
|
|
2
2
|
apply plugin: 'kotlin-android'
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
|
+
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
|
|
6
|
+
def packageVersion = packageJson.version
|
|
7
|
+
|
|
5
8
|
group = 'expo.modules.swipeable'
|
|
6
|
-
version =
|
|
9
|
+
version = packageVersion
|
|
7
10
|
|
|
8
11
|
buildscript {
|
|
9
12
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -44,7 +47,7 @@ android {
|
|
|
44
47
|
minSdkVersion safeExtGet("minSdkVersion", 23)
|
|
45
48
|
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
46
49
|
versionCode 1
|
|
47
|
-
versionName
|
|
50
|
+
versionName packageVersion
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
publishing {
|
|
@@ -78,6 +81,7 @@ repositories {
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
dependencies {
|
|
84
|
+
implementation "com.facebook.react:react-android"
|
|
81
85
|
implementation project(':expo-modules-core')
|
|
82
86
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
83
87
|
implementation "androidx.dynamicanimation:dynamicanimation:1.0.0"
|
|
@@ -12,6 +12,7 @@ import androidx.collection.LruCache
|
|
|
12
12
|
import androidx.dynamicanimation.animation.DynamicAnimation
|
|
13
13
|
import androidx.dynamicanimation.animation.SpringAnimation
|
|
14
14
|
import androidx.dynamicanimation.animation.SpringForce
|
|
15
|
+
import com.facebook.react.uimanager.events.NativeGestureUtil
|
|
15
16
|
import expo.modules.kotlin.AppContext
|
|
16
17
|
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
17
18
|
import expo.modules.kotlin.views.ExpoView
|
|
@@ -301,26 +302,7 @@ class SwipeableView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
301
302
|
* JSTouchDispatcher and JSPointerDispatcher to cancel tracking.
|
|
302
303
|
*/
|
|
303
304
|
private fun cancelReactTouches(event: MotionEvent) {
|
|
304
|
-
|
|
305
|
-
var currentView: ViewGroup? = parent as? ViewGroup
|
|
306
|
-
while (currentView != null) {
|
|
307
|
-
try {
|
|
308
|
-
// Try to find onChildStartedNativeGesture method
|
|
309
|
-
val method = currentView.javaClass.getMethod(
|
|
310
|
-
"onChildStartedNativeGesture",
|
|
311
|
-
View::class.java,
|
|
312
|
-
MotionEvent::class.java
|
|
313
|
-
)
|
|
314
|
-
method.invoke(currentView, this, event)
|
|
315
|
-
return
|
|
316
|
-
} catch (e: NoSuchMethodException) {
|
|
317
|
-
// Method not found, continue up the hierarchy
|
|
318
|
-
} catch (e: Exception) {
|
|
319
|
-
// Method found but invocation failed
|
|
320
|
-
break
|
|
321
|
-
}
|
|
322
|
-
currentView = currentView.parent as? ViewGroup
|
|
323
|
-
}
|
|
305
|
+
NativeGestureUtil.notifyNativeGestureStarted(this, event)
|
|
324
306
|
}
|
|
325
307
|
|
|
326
308
|
/**
|
|
@@ -18,12 +18,12 @@ function SwipeableActions({ children, actionsPosition }) {
|
|
|
18
18
|
}
|
|
19
19
|
const styles = react_native_1.StyleSheet.create({
|
|
20
20
|
actionsTrailing: {
|
|
21
|
-
...react_native_1.StyleSheet.
|
|
21
|
+
...react_native_1.StyleSheet.absoluteFill,
|
|
22
22
|
flexDirection: 'row',
|
|
23
23
|
justifyContent: 'flex-end'
|
|
24
24
|
},
|
|
25
25
|
actionsLeading: {
|
|
26
|
-
...react_native_1.StyleSheet.
|
|
26
|
+
...react_native_1.StyleSheet.absoluteFill,
|
|
27
27
|
flexDirection: 'row',
|
|
28
28
|
justifyContent: 'flex-start'
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwipeableActions.js","sourceRoot":"","sources":["../src/SwipeableActions.tsx"],"names":[],"mappings":";;;;;AAkBA,4CASC;AA3BD,kDAAwC;AACxC,+CAA+C;AAY/C;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAyB;IACnF,OAAO,CACL,CAAC,mBAAI,CACH,KAAK,CAAC,CAAC,eAAe,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CACnF,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAE1C;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,mBAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,eAAe,EAAE;QACf,GAAG,yBAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"SwipeableActions.js","sourceRoot":"","sources":["../src/SwipeableActions.tsx"],"names":[],"mappings":";;;;;AAkBA,4CASC;AA3BD,kDAAwC;AACxC,+CAA+C;AAY/C;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAyB;IACnF,OAAO,CACL,CAAC,mBAAI,CACH,KAAK,CAAC,CAAC,eAAe,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CACnF,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAE1C;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,mBAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,eAAe,EAAE;QACf,GAAG,yBAAU,CAAC,YAAY;QAC1B,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,UAAU;KAC3B;IACD,cAAc,EAAE;QACd,GAAG,yBAAU,CAAC,YAAY;QAC1B,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,YAAY;KAC7B;CACF,CAAC,CAAA"}
|
package/build/SwipeableView.js
CHANGED
|
@@ -8,4 +8,5 @@ exports.SwipeableModule = (0, expo_modules_core_1.requireNativeModule)('Swipeabl
|
|
|
8
8
|
exports.SwipeableView = (0, react_1.forwardRef)(function SwipeableView(props, ref) {
|
|
9
9
|
return (0, react_1.createElement)(NativeView, { ...props, ref });
|
|
10
10
|
});
|
|
11
|
+
exports.SwipeableView.displayName = 'SwipeableView';
|
|
11
12
|
//# sourceMappingURL=SwipeableView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwipeableView.js","sourceRoot":"","sources":["../src/SwipeableView.tsx"],"names":[],"mappings":";;;AAAA,iCAAiE;AACjE,yDAAiF;AAGjF,MAAM,UAAU,GAAG,IAAA,4CAAwB,EAAqB,WAAW,CAAC,CAAA;AAS/D,QAAA,eAAe,GAAG,IAAA,uCAAmB,EAAwB,WAAW,CAAC,CAAA;AAEzE,QAAA,aAAa,GAAG,IAAA,kBAAU,EACrC,SAAS,aAAa,CAAC,KAAK,EAAE,GAAG;IAC/B,OAAO,IAAA,qBAAa,EAAC,UAAU,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAuC,CAAC,CAAA;AAC1F,CAAC,CACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"SwipeableView.js","sourceRoot":"","sources":["../src/SwipeableView.tsx"],"names":[],"mappings":";;;AAAA,iCAAiE;AACjE,yDAAiF;AAGjF,MAAM,UAAU,GAAG,IAAA,4CAAwB,EAAqB,WAAW,CAAC,CAAA;AAS/D,QAAA,eAAe,GAAG,IAAA,uCAAmB,EAAwB,WAAW,CAAC,CAAA;AAEzE,QAAA,aAAa,GAAG,IAAA,kBAAU,EACrC,SAAS,aAAa,CAAC,KAAK,EAAE,GAAG;IAC/B,OAAO,IAAA,qBAAa,EAAC,UAAU,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAuC,CAAC,CAAA;AAC1F,CAAC,CACF,CAAA;AAED,qBAAa,CAAC,WAAW,GAAG,eAAe,CAAA"}
|
package/build/index.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ export { default as Swipeable } from './Swipeable';
|
|
|
2
2
|
export { SwipeableView } from './SwipeableView';
|
|
3
3
|
export type { SwipeableProps, SwipeableMethods, SwipeableStatic, SwipeableViewProps, SwipeProgressEvent, SwipeStateEvent, NativeSwipeableRef } from './Swipeable.types';
|
|
4
4
|
export { SWIPE_PROGRESS, SWIPE_DEFAULTS } from './constants';
|
|
5
|
-
export { isSwipeFullyOpen, isSwipeFullyClosed, calculateSwipeStateChange } from './swipeStateUtils';
|
|
6
|
-
export type { SwipeState, SwipeStateChange } from './swipeStateUtils';
|
|
7
5
|
export { setGlobalErrorHandler } from './nativeModuleUtils';
|
|
8
6
|
export type { SwipeableErrorHandler, NativeModuleError } from './nativeModuleUtils';
|
|
9
7
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAG5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setGlobalErrorHandler = exports.
|
|
6
|
+
exports.setGlobalErrorHandler = exports.SWIPE_DEFAULTS = exports.SWIPE_PROGRESS = exports.SwipeableView = exports.Swipeable = void 0;
|
|
7
7
|
var Swipeable_1 = require("./Swipeable");
|
|
8
8
|
Object.defineProperty(exports, "Swipeable", { enumerable: true, get: function () { return __importDefault(Swipeable_1).default; } });
|
|
9
9
|
var SwipeableView_1 = require("./SwipeableView");
|
|
@@ -11,10 +11,6 @@ Object.defineProperty(exports, "SwipeableView", { enumerable: true, get: functio
|
|
|
11
11
|
var constants_1 = require("./constants");
|
|
12
12
|
Object.defineProperty(exports, "SWIPE_PROGRESS", { enumerable: true, get: function () { return constants_1.SWIPE_PROGRESS; } });
|
|
13
13
|
Object.defineProperty(exports, "SWIPE_DEFAULTS", { enumerable: true, get: function () { return constants_1.SWIPE_DEFAULTS; } });
|
|
14
|
-
var swipeStateUtils_1 = require("./swipeStateUtils");
|
|
15
|
-
Object.defineProperty(exports, "isSwipeFullyOpen", { enumerable: true, get: function () { return swipeStateUtils_1.isSwipeFullyOpen; } });
|
|
16
|
-
Object.defineProperty(exports, "isSwipeFullyClosed", { enumerable: true, get: function () { return swipeStateUtils_1.isSwipeFullyClosed; } });
|
|
17
|
-
Object.defineProperty(exports, "calculateSwipeStateChange", { enumerable: true, get: function () { return swipeStateUtils_1.calculateSwipeStateChange; } });
|
|
18
14
|
// Error handling utilities
|
|
19
15
|
var nativeModuleUtils_1 = require("./nativeModuleUtils");
|
|
20
16
|
Object.defineProperty(exports, "setGlobalErrorHandler", { enumerable: true, get: function () { return nativeModuleUtils_1.setGlobalErrorHandler; } });
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAkD;AAAzC,uHAAA,OAAO,OAAa;AAC7B,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;AAYtB,yCAA4D;AAAnD,2GAAA,cAAc,OAAA;AAAE,2GAAA,cAAc,OAAA;AAEvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAkD;AAAzC,uHAAA,OAAO,OAAa;AAC7B,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;AAYtB,yCAA4D;AAAnD,2GAAA,cAAc,OAAA;AAAE,2GAAA,cAAc,OAAA;AAEvC,2BAA2B;AAC3B,yDAA2D;AAAlD,0HAAA,qBAAqB,OAAA"}
|
package/jestSetup.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
jest.mock('./src/SwipeableView.tsx', () => {
|
|
2
|
+
const React = require('react')
|
|
3
|
+
const { View } = require('react-native')
|
|
4
|
+
|
|
5
|
+
const SwipeableModule = {
|
|
6
|
+
openByKey: jest.fn(),
|
|
7
|
+
closeByKey: jest.fn(),
|
|
8
|
+
closeAll: jest.fn()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const SwipeableView = React.forwardRef((props, ref) => {
|
|
12
|
+
const {
|
|
13
|
+
children,
|
|
14
|
+
onSwipeStart,
|
|
15
|
+
testID,
|
|
16
|
+
...rest
|
|
17
|
+
} = props
|
|
18
|
+
|
|
19
|
+
React.useImperativeHandle(ref, () => ({
|
|
20
|
+
close: jest.fn(),
|
|
21
|
+
open: jest.fn()
|
|
22
|
+
}), [])
|
|
23
|
+
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
onSwipeStart?.()
|
|
26
|
+
}, [onSwipeStart])
|
|
27
|
+
|
|
28
|
+
return React.createElement(
|
|
29
|
+
View,
|
|
30
|
+
{
|
|
31
|
+
testID: testID || 'SwipeableView',
|
|
32
|
+
...rest
|
|
33
|
+
},
|
|
34
|
+
children
|
|
35
|
+
)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
SwipeableView.displayName = 'SwipeableView'
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
SwipeableModule,
|
|
42
|
+
SwipeableView
|
|
43
|
+
}
|
|
44
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-swipeable-actions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "High-performance native swipeable row component for React Native using Expo Modules",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"!ios/.build",
|
|
15
15
|
"android/src/main",
|
|
16
16
|
"android/build.gradle",
|
|
17
|
-
"expo-module.config.json"
|
|
17
|
+
"expo-module.config.json",
|
|
18
|
+
"jestSetup.js"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
21
|
"build": "tsc",
|
|
@@ -79,7 +80,6 @@
|
|
|
79
80
|
"react": "19.1.1",
|
|
80
81
|
"react-native": "0.82.1",
|
|
81
82
|
"react-test-renderer": "19.1.1",
|
|
82
|
-
"ts-jest": "^29.1.0",
|
|
83
83
|
"typescript": "^5.9.3"
|
|
84
84
|
}
|
|
85
85
|
}
|
package/src/SwipeableActions.tsx
CHANGED
|
@@ -29,12 +29,12 @@ export function SwipeableActions({ children, actionsPosition }: SwipeableActions
|
|
|
29
29
|
|
|
30
30
|
const styles = StyleSheet.create({
|
|
31
31
|
actionsTrailing: {
|
|
32
|
-
...StyleSheet.
|
|
32
|
+
...StyleSheet.absoluteFill,
|
|
33
33
|
flexDirection: 'row',
|
|
34
34
|
justifyContent: 'flex-end'
|
|
35
35
|
},
|
|
36
36
|
actionsLeading: {
|
|
37
|
-
...StyleSheet.
|
|
37
|
+
...StyleSheet.absoluteFill,
|
|
38
38
|
flexDirection: 'row',
|
|
39
39
|
justifyContent: 'flex-start'
|
|
40
40
|
}
|
package/src/SwipeableView.tsx
CHANGED
package/src/index.ts
CHANGED
|
@@ -13,10 +13,6 @@ export type {
|
|
|
13
13
|
|
|
14
14
|
export { SWIPE_PROGRESS, SWIPE_DEFAULTS } from './constants'
|
|
15
15
|
|
|
16
|
-
export { isSwipeFullyOpen, isSwipeFullyClosed, calculateSwipeStateChange } from './swipeStateUtils'
|
|
17
|
-
|
|
18
|
-
export type { SwipeState, SwipeStateChange } from './swipeStateUtils'
|
|
19
|
-
|
|
20
16
|
// Error handling utilities
|
|
21
17
|
export { setGlobalErrorHandler } from './nativeModuleUtils'
|
|
22
18
|
export type { SwipeableErrorHandler, NativeModuleError } from './nativeModuleUtils'
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface SwipeState {
|
|
2
|
-
wasOpen: boolean;
|
|
3
|
-
swipeStarted: boolean;
|
|
4
|
-
}
|
|
5
|
-
export interface SwipeStateChange {
|
|
6
|
-
nextState: SwipeState;
|
|
7
|
-
shouldEmitEnd: boolean;
|
|
8
|
-
/** Whether the open state changed (for onOpenChange callback) */
|
|
9
|
-
openStateChanged?: boolean;
|
|
10
|
-
/** The new open state (true = opened, false = closed) */
|
|
11
|
-
newOpenState?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function isSwipeFullyOpen(progress: number): boolean;
|
|
14
|
-
export declare function isSwipeFullyClosed(progress: number): boolean;
|
|
15
|
-
export declare function calculateSwipeStateChange(progress: number, currentState: SwipeState): SwipeStateChange;
|
|
16
|
-
//# sourceMappingURL=swipeStateUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swipeStateUtils.d.ts","sourceRoot":"","sources":["../src/swipeStateUtils.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,UAAU,CAAA;IACrB,aAAa,EAAE,OAAO,CAAA;IACtB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,yDAAyD;IACzD,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,UAAU,GACvB,gBAAgB,CA2BlB"}
|
package/build/swipeStateUtils.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSwipeFullyOpen = isSwipeFullyOpen;
|
|
4
|
-
exports.isSwipeFullyClosed = isSwipeFullyClosed;
|
|
5
|
-
exports.calculateSwipeStateChange = calculateSwipeStateChange;
|
|
6
|
-
const constants_1 = require("./constants");
|
|
7
|
-
function isSwipeFullyOpen(progress) {
|
|
8
|
-
return progress >= constants_1.SWIPE_PROGRESS.OPEN_THRESHOLD;
|
|
9
|
-
}
|
|
10
|
-
function isSwipeFullyClosed(progress) {
|
|
11
|
-
return progress <= constants_1.SWIPE_PROGRESS.CLOSED_THRESHOLD;
|
|
12
|
-
}
|
|
13
|
-
function calculateSwipeStateChange(progress, currentState) {
|
|
14
|
-
const isOpen = isSwipeFullyOpen(progress);
|
|
15
|
-
const isClosed = isSwipeFullyClosed(progress);
|
|
16
|
-
if (!currentState.swipeStarted) {
|
|
17
|
-
return { nextState: currentState, shouldEmitEnd: false };
|
|
18
|
-
}
|
|
19
|
-
if (isOpen && !currentState.wasOpen) {
|
|
20
|
-
return {
|
|
21
|
-
nextState: { wasOpen: true, swipeStarted: false },
|
|
22
|
-
shouldEmitEnd: true,
|
|
23
|
-
openStateChanged: true,
|
|
24
|
-
newOpenState: true
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
if (isClosed && currentState.wasOpen) {
|
|
28
|
-
return {
|
|
29
|
-
nextState: { wasOpen: false, swipeStarted: false },
|
|
30
|
-
shouldEmitEnd: true,
|
|
31
|
-
openStateChanged: true,
|
|
32
|
-
newOpenState: false
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return { nextState: currentState, shouldEmitEnd: false };
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=swipeStateUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swipeStateUtils.js","sourceRoot":"","sources":["../src/swipeStateUtils.ts"],"names":[],"mappings":";;AAgBA,4CAEC;AAED,gDAEC;AAED,8DA8BC;AAtDD,2CAA4C;AAgB5C,SAAgB,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,QAAQ,IAAI,0BAAc,CAAC,cAAc,CAAA;AAClD,CAAC;AAED,SAAgB,kBAAkB,CAAC,QAAgB;IACjD,OAAO,QAAQ,IAAI,0BAAc,CAAC,gBAAgB,CAAA;AACpD,CAAC;AAED,SAAgB,yBAAyB,CACvC,QAAgB,EAChB,YAAwB;IAExB,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IAE7C,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;QAC/B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,CAAA;IAC1D,CAAC;IAED,IAAI,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QACpC,OAAO;YACL,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE;YACjD,aAAa,EAAE,IAAI;YACnB,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,IAAI;SACnB,CAAA;IACH,CAAC;IAED,IAAI,QAAQ,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;QACrC,OAAO;YACL,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE;YAClD,aAAa,EAAE,IAAI;YACnB,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,KAAK;SACpB,CAAA;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,CAAA;AAC1D,CAAC"}
|
package/src/swipeStateUtils.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { SWIPE_PROGRESS } from './constants'
|
|
2
|
-
|
|
3
|
-
export interface SwipeState {
|
|
4
|
-
wasOpen: boolean
|
|
5
|
-
swipeStarted: boolean
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface SwipeStateChange {
|
|
9
|
-
nextState: SwipeState
|
|
10
|
-
shouldEmitEnd: boolean
|
|
11
|
-
/** Whether the open state changed (for onOpenChange callback) */
|
|
12
|
-
openStateChanged?: boolean
|
|
13
|
-
/** The new open state (true = opened, false = closed) */
|
|
14
|
-
newOpenState?: boolean
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function isSwipeFullyOpen(progress: number): boolean {
|
|
18
|
-
return progress >= SWIPE_PROGRESS.OPEN_THRESHOLD
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function isSwipeFullyClosed(progress: number): boolean {
|
|
22
|
-
return progress <= SWIPE_PROGRESS.CLOSED_THRESHOLD
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function calculateSwipeStateChange(
|
|
26
|
-
progress: number,
|
|
27
|
-
currentState: SwipeState
|
|
28
|
-
): SwipeStateChange {
|
|
29
|
-
const isOpen = isSwipeFullyOpen(progress)
|
|
30
|
-
const isClosed = isSwipeFullyClosed(progress)
|
|
31
|
-
|
|
32
|
-
if (!currentState.swipeStarted) {
|
|
33
|
-
return { nextState: currentState, shouldEmitEnd: false }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (isOpen && !currentState.wasOpen) {
|
|
37
|
-
return {
|
|
38
|
-
nextState: { wasOpen: true, swipeStarted: false },
|
|
39
|
-
shouldEmitEnd: true,
|
|
40
|
-
openStateChanged: true,
|
|
41
|
-
newOpenState: true
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (isClosed && currentState.wasOpen) {
|
|
46
|
-
return {
|
|
47
|
-
nextState: { wasOpen: false, swipeStarted: false },
|
|
48
|
-
shouldEmitEnd: true,
|
|
49
|
-
openStateChanged: true,
|
|
50
|
-
newOpenState: false
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return { nextState: currentState, shouldEmitEnd: false }
|
|
55
|
-
}
|