@rootnative/inertia 0.0.0-alpha.2 → 0.0.0-alpha.3

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.
@@ -1,52 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var chunkSFRNO6AW_js = require('../chunk-SFRNO6AW.js');
3
4
  var react = require('react');
4
5
  var reactNative = require('react-native');
5
6
  var reactNativeReanimated = require('react-native-reanimated');
6
7
 
7
- // src/touch/useTouchDrag.ts
8
-
9
- // src/transitions/spring.ts
10
- var DEFAULT_SPRING = {
11
- tension: 170,
12
- friction: 26,
13
- mass: 1
14
- };
15
- function springToReanimated(t) {
16
- "worklet";
17
- return {
18
- stiffness: t.tension ?? DEFAULT_SPRING.tension,
19
- damping: t.friction ?? DEFAULT_SPRING.friction,
20
- mass: t.mass ?? DEFAULT_SPRING.mass,
21
- velocity: t.velocity,
22
- restSpeedThreshold: t.restSpeedThreshold,
23
- restDisplacementThreshold: t.restDisplacementThreshold
24
- };
25
- }
26
- var DEFAULT_TIMING_DURATION = 250;
27
- function buildReleaseAnimation(transition, toValue) {
28
- "worklet";
29
- if (transition.type === "no-animation") return toValue;
30
- if (transition.type === "decay") {
31
- const cfg = { velocity: transition.velocity ?? 0 };
32
- if (transition.deceleration !== void 0) {
33
- cfg.deceleration = transition.deceleration;
34
- }
35
- if (transition.clamp !== void 0) cfg.clamp = transition.clamp;
36
- return reactNativeReanimated.withDecay(cfg);
37
- }
38
- if (transition.type === "timing") {
39
- const e = transition.easing;
40
- const easingFn = e && typeof e === "object" && "factory" in e ? e.factory() : e ?? reactNativeReanimated.Easing.inOut(reactNativeReanimated.Easing.ease);
41
- return reactNativeReanimated.withTiming(toValue, {
42
- duration: transition.duration ?? DEFAULT_TIMING_DURATION,
43
- easing: easingFn
44
- });
45
- }
46
- return reactNativeReanimated.withSpring(toValue, springToReanimated(transition));
47
- }
48
-
49
- // src/touch/useTouchDrag.ts
50
8
  function useTouchDrag(options = {}) {
51
9
  const { axis = "both", constraints, elastic = 0 } = options;
52
10
  const dragX = reactNativeReanimated.useSharedValue(0);
@@ -90,14 +48,14 @@ function useTouchDrag(options = {}) {
90
48
  if (result) {
91
49
  if (result.x && lockX) {
92
50
  const toX = "to" in result.x ? result.x.to : x;
93
- dragX.value = buildReleaseAnimation(
51
+ dragX.value = chunkSFRNO6AW_js.buildReleaseAnimation(
94
52
  result.x,
95
53
  toX
96
54
  );
97
55
  }
98
56
  if (result.y && lockY) {
99
57
  const toY = "to" in result.y ? result.y.to : y;
100
- dragY.value = buildReleaseAnimation(
58
+ dragY.value = chunkSFRNO6AW_js.buildReleaseAnimation(
101
59
  result.y,
102
60
  toY
103
61
  );
@@ -1,50 +1,8 @@
1
+ import { buildReleaseAnimation } from '../chunk-6FENLMCA.mjs';
1
2
  import { useMemo } from 'react';
2
3
  import { PanResponder } from 'react-native';
3
- import { useSharedValue, useAnimatedStyle, withDecay, Easing, withTiming, withSpring } from 'react-native-reanimated';
4
+ import { useSharedValue, useAnimatedStyle } from 'react-native-reanimated';
4
5
 
5
- // src/touch/useTouchDrag.ts
6
-
7
- // src/transitions/spring.ts
8
- var DEFAULT_SPRING = {
9
- tension: 170,
10
- friction: 26,
11
- mass: 1
12
- };
13
- function springToReanimated(t) {
14
- "worklet";
15
- return {
16
- stiffness: t.tension ?? DEFAULT_SPRING.tension,
17
- damping: t.friction ?? DEFAULT_SPRING.friction,
18
- mass: t.mass ?? DEFAULT_SPRING.mass,
19
- velocity: t.velocity,
20
- restSpeedThreshold: t.restSpeedThreshold,
21
- restDisplacementThreshold: t.restDisplacementThreshold
22
- };
23
- }
24
- var DEFAULT_TIMING_DURATION = 250;
25
- function buildReleaseAnimation(transition, toValue) {
26
- "worklet";
27
- if (transition.type === "no-animation") return toValue;
28
- if (transition.type === "decay") {
29
- const cfg = { velocity: transition.velocity ?? 0 };
30
- if (transition.deceleration !== void 0) {
31
- cfg.deceleration = transition.deceleration;
32
- }
33
- if (transition.clamp !== void 0) cfg.clamp = transition.clamp;
34
- return withDecay(cfg);
35
- }
36
- if (transition.type === "timing") {
37
- const e = transition.easing;
38
- const easingFn = e && typeof e === "object" && "factory" in e ? e.factory() : e ?? Easing.inOut(Easing.ease);
39
- return withTiming(toValue, {
40
- duration: transition.duration ?? DEFAULT_TIMING_DURATION,
41
- easing: easingFn
42
- });
43
- }
44
- return withSpring(toValue, springToReanimated(transition));
45
- }
46
-
47
- // src/touch/useTouchDrag.ts
48
6
  function useTouchDrag(options = {}) {
49
7
  const { axis = "both", constraints, elastic = 0 } = options;
50
8
  const dragX = useSharedValue(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rootnative/inertia",
3
- "version": "0.0.0-alpha.2",
3
+ "version": "0.0.0-alpha.3",
4
4
  "description": "Declarative animation primitives for React Native, built on react-native-reanimated.",
5
5
  "license": "MIT",
6
6
  "author": "RootNative",