Skip to content

Commit eb9c828

Browse files
committed
feat: fix haptics
1 parent f8da3e9 commit eb9c828

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/charts/linear/ChartPath.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Platform } from 'react-native';
99
import { LongPressGestureHandler } from 'react-native-gesture-handler';
1010
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
1111
import Animated, {
12+
runOnJS,
1213
useAnimatedGestureHandler,
1314
useAnimatedStyle,
1415
useDerivedValue,
@@ -26,8 +27,8 @@ import { svgBezierPath } from '../../smoothing/smoothSVG';
2627

2728
function impactHeavy() {
2829
'worklet';
29-
(Animated.runOnJS
30-
? Animated.runOnJS(ReactNativeHapticFeedback.trigger)
30+
(runOnJS
31+
? runOnJS(ReactNativeHapticFeedback.trigger)
3132
: ReactNativeHapticFeedback.trigger)('impactHeavy');
3233
}
3334

@@ -108,6 +109,7 @@ function setoriginalXYAccordingToPosition(
108109
// prevent the following error on android:
109110
// java.lang.RuntimeException: undefined is not an object (evaluating 'data.value[idx].originalX')
110111
// why data.value = [] sometimes onActive?
112+
// eslint-disable-next-line no-console
111113
console.warn('No data available for chart', data.value.length, idx);
112114
return;
113115
}
@@ -219,7 +221,7 @@ export default function ChartPathProvider({
219221
const [parsedoriginalData, newExtremes] = parse(
220222
data.nativePoints || data.points
221223
);
222-
setContextValue((prev) => ({ ...prev, ...newExtremes, data }));
224+
setContextValue(prev => ({ ...prev, ...newExtremes, data }));
223225
setExtremes(newExtremes);
224226
if (prevData.value.length !== 0) {
225227
valuesStore.current.prevData = currData.value;
@@ -262,7 +264,7 @@ export default function ChartPathProvider({
262264
const isStarted = useSharedValue(false, 'isStarted');
263265

264266
const onLongPressGestureEvent = useAnimatedGestureHandler({
265-
onActive: (event) => {
267+
onActive: event => {
266268
state.value = event.state;
267269
if (!currData.value || currData.value.length === 0) {
268270
return;
@@ -340,7 +342,7 @@ export default function ChartPathProvider({
340342
);
341343
positionX.value = eventX;
342344
},
343-
onCancel: (event) => {
345+
onCancel: event => {
344346
isStarted.value = false;
345347
state.value = event.state;
346348
originalX.value = '';
@@ -358,7 +360,7 @@ export default function ChartPathProvider({
358360
);
359361
}
360362
},
361-
onEnd: (event) => {
363+
onEnd: event => {
362364
isStarted.value = false;
363365
state.value = event.state;
364366
originalX.value = '';
@@ -380,7 +382,7 @@ export default function ChartPathProvider({
380382
impactHeavy();
381383
}
382384
},
383-
onFail: (event) => {
385+
onFail: event => {
384386
isStarted.value = false;
385387
state.value = event.state;
386388
originalX.value = '';
@@ -398,7 +400,7 @@ export default function ChartPathProvider({
398400
);
399401
}
400402
},
401-
onStart: (event) => {
403+
onStart: event => {
402404
// WARNING: the following code does not run on using iOS, but it does on Android.
403405
// I use the same code from onActive except of "progress.value = 1" which was taken from the original onStart.
404406
state.value = event.state;

src/interpolations/bSplineInterpolation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class BSpline {
3030
seqAt(dim) {
3131
let points = this.points;
3232
let margin = this.degree + 1;
33-
return function(n) {
33+
return function (n) {
3434
if (n < margin) {
3535
return points[0][dim];
3636
} else if (points.length + margin <= n) {

0 commit comments

Comments
 (0)