Skip to content

Commit de7371a

Browse files
author
Andrzej Antoni Kwaśniewski
committed
removed worklet directive
1 parent c3d9d8f commit de7371a

22 files changed

Lines changed: 18 additions & 139 deletions

File tree

apps/common-app/src/new_api/complicated/camera/index.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ export default function Camera() {
4444

4545
const filterChangeGesture = usePanGesture({
4646
onUpdate: (e) => {
47-
'worklet';
4847
selectedFilter.value -= e.changeX / FILTER_SIZE;
4948
},
5049
onDeactivate: () => {
51-
'worklet';
5250
const nextFilter = Math.min(
5351
FILTERS.length - 1,
5452
Math.max(0, Math.round(selectedFilter.value))
@@ -81,15 +79,13 @@ export default function Camera() {
8179
shouldCancelWhenOutside: false,
8280
maxDistance: 10000,
8381
onActivate: () => {
84-
'worklet';
8582
runOnJS(startRecording)();
8683
captureProgress.value = withTiming(1, {
8784
duration: VIDEO_DURATION,
8885
easing: (x) => x,
8986
});
9087
},
9188
onDeactivate: () => {
92-
'worklet';
9389
runOnJS(stopRecording)();
9490
captureProgress.value = 0;
9591
},
@@ -99,14 +95,12 @@ export default function Camera() {
9995
shouldCancelWhenOutside: false,
10096
requireToFail: filterChangeGesture,
10197
onUpdate: (e) => {
102-
'worklet';
10398
zoom.value = Math.max(1, Math.min(2, zoom.value - e.changeY / 500));
10499
},
105100
});
106101

107102
const pinchZoomGesture = usePinchGesture({
108103
onUpdate: (e) => {
109-
'worklet';
110104
zoom.value = Math.max(
111105
1,
112106
Math.min(2, zoom.value * ((e.scaleChange - 1) * 0.2 + 1))
@@ -118,7 +112,6 @@ export default function Camera() {
118112
const changeCameraGesture = useTapGesture({
119113
numberOfTaps: 2,
120114
onDeactivate: () => {
121-
'worklet';
122115
setFacing((f) => (f === 'back' ? 'front' : 'back'));
123116
},
124117
disableReanimated: true,

apps/common-app/src/new_api/complicated/chat_heads/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,10 @@ const Example = () => {
9393

9494
const panHandler = usePanGesture({
9595
onUpdate: (e) => {
96-
'worklet';
9796
panOffset.x.value = mainChatHeadPosition.x.value + e.translationX;
9897
panOffset.y.value = mainChatHeadPosition.y.value + e.translationY;
9998
},
10099
onDeactivate: (e) => {
101-
'worklet';
102100
const { height, width } = dimensions;
103101

104102
const velocityDragX = clampToValues({

apps/common-app/src/new_api/complicated/lock/index.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export default function Lock() {
3434
// Tap to lock
3535
const tap = useTapGesture({
3636
onDeactivate: () => {
37-
'worklet';
3837
if (savedRotation.value === 0 && scale.value === maxScale) {
3938
runOnJS(setLocked)(false);
4039
}
@@ -48,16 +47,13 @@ export default function Lock() {
4847

4948
const rotationGesture = useRotationGesture({
5049
onUpdate: (e) => {
51-
'worklet';
5250
rotation.value = savedRotation.value + e.rotation;
5351

5452
if (!locked) {
5553
runOnJS(setLocked)(true);
5654
}
5755
},
5856
onDeactivate: () => {
59-
'worklet';
60-
6157
const nearestMultiple = Math.round(rotation.value / TWO_PI) * TWO_PI;
6258

6359
if (Math.abs(rotation.value - nearestMultiple) < snapThreshold) {
@@ -73,7 +69,6 @@ export default function Lock() {
7369

7470
const pinchGesture = usePinchGesture({
7571
onUpdate: (e) => {
76-
'worklet';
7772
const value = savedScale.value * e.scale;
7873
if (value < minScale || value > maxScale) {
7974
return;
@@ -85,8 +80,6 @@ export default function Lock() {
8580
}
8681
},
8782
onDeactivate: () => {
88-
'worklet';
89-
9083
if (Math.abs(scale.value - maxScale) < scaleThreshold) {
9184
scale.value = withTiming(maxScale, { duration: 300 });
9285
} else {

apps/common-app/src/new_api/platform_specific/hover/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,16 @@ function useColoredHover(
2323

2424
const gesture = useHoverGesture({
2525
onBegin: () => {
26-
'worklet';
2726
hovered.value = true;
2827
feedbackRef.current?.showMessage('Hover begin ' + color);
2928
},
3029
onActivate: () => {
31-
'worklet';
3230
console.log('hover start', color);
3331
},
3432
onDeactivate: (_, success) => {
35-
'worklet';
3633
console.log('hover end', color, 'failed', !success);
3734
},
3835
onFinalize: () => {
39-
'worklet';
4036
hovered.value = false;
4137
console.log('hover finalize', color);
4238
},

apps/common-app/src/new_api/platform_specific/hoverable_icons/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,16 @@ function BoxReanimated(props: { source: any }) {
5656

5757
const hover = useHoverGesture({
5858
onBegin: () => {
59-
'worklet';
6059
scale.value = withTiming(1.15, { duration: 100 });
6160
},
6261
onUpdate: (e) => {
63-
'worklet';
6462
const oX = e.x - SIZE / 2;
6563
const oY = e.y - SIZE / 2;
6664

6765
targetOffsetX.value = Math.pow(Math.abs(oX), 0.3) * Math.sign(oX);
6866
targetOffsetY.value = Math.pow(Math.abs(oY), 0.3) * Math.sign(oY);
6967
},
7068
onFinalize: () => {
71-
'worklet';
7269
scale.value = withTiming(1, { duration: 100 });
7370
targetOffsetX.value = 0;
7471
targetOffsetY.value = 0;

apps/common-app/src/new_api/platform_specific/mouse_buttons/index.tsx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export default function Buttons() {
5252
const leftTap = useTapGesture({
5353
mouseButton: MouseButton.LEFT,
5454
onDeactivate: () => {
55-
'worklet';
5655
feedbackRef.current?.showMessage('Tap with left');
5756
},
5857
disableReanimated: true,
@@ -61,7 +60,6 @@ export default function Buttons() {
6160
const middleTap = useTapGesture({
6261
mouseButton: MouseButton.MIDDLE,
6362
onDeactivate: () => {
64-
'worklet';
6563
feedbackRef.current?.showMessage('Tap with middle');
6664
},
6765
disableReanimated: true,
@@ -70,7 +68,6 @@ export default function Buttons() {
7068
const rightTap = useTapGesture({
7169
mouseButton: MouseButton.RIGHT,
7270
onDeactivate: () => {
73-
'worklet';
7471
feedbackRef.current?.showMessage('Tap with right');
7572
},
7673
disableReanimated: true,
@@ -79,7 +76,6 @@ export default function Buttons() {
7976
const leftRightTap = useTapGesture({
8077
mouseButton: MouseButton.LEFT | MouseButton.RIGHT,
8178
onDeactivate: () => {
82-
'worklet';
8379
feedbackRef.current?.showMessage('Tap with left | right');
8480
},
8581
disableReanimated: true,
@@ -88,7 +84,6 @@ export default function Buttons() {
8884
const allTap = useTapGesture({
8985
mouseButton: MouseButton.ALL,
9086
onDeactivate: () => {
91-
'worklet';
9287
feedbackRef.current?.showMessage('Tap with any button');
9388
},
9489
disableReanimated: true,
@@ -103,39 +98,34 @@ export default function Buttons() {
10398
const leftPan = usePanGesture({
10499
mouseButton: MouseButton.LEFT,
105100
onUpdate: () => {
106-
'worklet';
107101
feedbackRef.current?.showMessage('Panning with left');
108102
},
109103
});
110104

111105
const middlePan = usePanGesture({
112106
mouseButton: MouseButton.MIDDLE,
113107
onUpdate: () => {
114-
'worklet';
115108
feedbackRef.current?.showMessage('Panning with middle');
116109
},
117110
});
118111

119112
const rightPan = usePanGesture({
120113
mouseButton: MouseButton.RIGHT,
121114
onUpdate: () => {
122-
'worklet';
123115
feedbackRef.current?.showMessage('Panning with right');
124116
},
125117
});
126118

127119
const leftRightPan = usePanGesture({
128120
mouseButton: MouseButton.LEFT | MouseButton.RIGHT,
129121
onUpdate: () => {
130-
'worklet';
131122
feedbackRef.current?.showMessage('Panning with left | right');
132123
},
133124
});
134125

135126
const allPan = usePanGesture({
136127
mouseButton: MouseButton.ALL,
137128
onUpdate: () => {
138-
'worklet';
139129
feedbackRef.current?.showMessage('Panning with any button');
140130
},
141131
});
@@ -149,39 +139,34 @@ export default function Buttons() {
149139
const leftLongPress = useLongPressGesture({
150140
mouseButton: MouseButton.LEFT,
151141
onActivate: () => {
152-
'worklet';
153142
feedbackRef.current?.showMessage('LongPress with left');
154143
},
155144
});
156145

157146
const middleLongPress = useLongPressGesture({
158147
mouseButton: MouseButton.MIDDLE,
159148
onActivate: () => {
160-
'worklet';
161149
feedbackRef.current?.showMessage('LongPress with middle');
162150
},
163151
});
164152

165153
const rightLongPress = useLongPressGesture({
166154
mouseButton: MouseButton.RIGHT,
167155
onActivate: () => {
168-
'worklet';
169156
feedbackRef.current?.showMessage('LongPress with right');
170157
},
171158
});
172159

173160
const leftRightLongPress = useLongPressGesture({
174161
mouseButton: MouseButton.LEFT | MouseButton.RIGHT,
175162
onActivate: () => {
176-
'worklet';
177163
feedbackRef.current?.showMessage('LongPress with left | right');
178164
},
179165
});
180166

181167
const allLongPress = useLongPressGesture({
182168
mouseButton: MouseButton.ALL,
183169
onActivate: () => {
184-
'worklet';
185170
feedbackRef.current?.showMessage('LongPress with any button');
186171
},
187172
});
@@ -202,7 +187,6 @@ export default function Buttons() {
202187
direction: Directions.LEFT | Directions.RIGHT,
203188
mouseButton: MouseButton.LEFT,
204189
onActivate: () => {
205-
'worklet';
206190
feedbackRef.current?.showMessage('Fling with left');
207191
},
208192
});
@@ -211,7 +195,6 @@ export default function Buttons() {
211195
direction: Directions.LEFT | Directions.RIGHT,
212196
mouseButton: MouseButton.MIDDLE,
213197
onActivate: () => {
214-
'worklet';
215198
feedbackRef.current?.showMessage('Fling with middle');
216199
},
217200
});
@@ -220,7 +203,6 @@ export default function Buttons() {
220203
direction: Directions.LEFT | Directions.RIGHT,
221204
mouseButton: MouseButton.RIGHT,
222205
onActivate: () => {
223-
'worklet';
224206
feedbackRef.current?.showMessage('Fling with right');
225207
},
226208
});
@@ -229,7 +211,6 @@ export default function Buttons() {
229211
direction: Directions.LEFT | Directions.RIGHT,
230212
mouseButton: MouseButton.LEFT | MouseButton.RIGHT,
231213
onActivate: () => {
232-
'worklet';
233214
feedbackRef.current?.showMessage('Fling with left | right');
234215
},
235216
});
@@ -238,7 +219,6 @@ export default function Buttons() {
238219
direction: Directions.LEFT | Directions.RIGHT,
239220
mouseButton: MouseButton.ALL,
240221
onActivate: () => {
241-
'worklet';
242222
feedbackRef.current?.showMessage('Fling with any button');
243223
},
244224
});

apps/common-app/src/new_api/platform_specific/stylus_data/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export default function StylusData() {
1717

1818
const pan = usePanGesture({
1919
onBegin: (e) => {
20-
'worklet';
2120
if (!e.stylusData) {
2221
return;
2322
}
@@ -27,7 +26,6 @@ export default function StylusData() {
2726
rotationXFactor.value = e.stylusData.tiltY;
2827
},
2928
onUpdate: (e) => {
30-
'worklet';
3129
if (!e.stylusData) {
3230
return;
3331
}
@@ -37,7 +35,6 @@ export default function StylusData() {
3735
rotationXFactor.value = e.stylusData.tiltY;
3836
},
3937
onFinalize: (e) => {
40-
'worklet';
4138
if (!e.stylusData) {
4239
return;
4340
}

apps/common-app/src/new_api/showcase/animated/index.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@ export default function MinimalCard() {
2525
}).start();
2626
},
2727
onActivate: () => {
28-
'worklet';
29-
3028
Animated.spring(scale, {
3129
toValue: 1.05,
3230
useNativeDriver: true,
3331
}).start();
3432
},
3533
onUpdate: (e) => {
36-
'worklet';
37-
3834
translateX.setValue(e.translationX + offsetX);
3935
translateY.setValue(e.translationY + offsetY);
4036

@@ -46,8 +42,6 @@ export default function MinimalCard() {
4642
);
4743
},
4844
onDeactivate: (e) => {
49-
'worklet';
50-
5145
Animated.spring(scale, {
5246
toValue: 1,
5347
useNativeDriver: true,

apps/common-app/src/new_api/showcase/bottom_sheet/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ function Example() {
3939
setSnapPoint(point);
4040
};
4141
const onHandlerDeactivate = (e: PanGestureEvent) => {
42-
'worklet';
4342
const dragToss = 0.01;
4443
const endOffsetY =
4544
bottomSheetTranslateY.value + translationY.value + e.velocityY * dragToss;
@@ -72,7 +71,6 @@ function Example() {
7271
};
7372
const panGesture = usePanGesture({
7473
onUpdate: (e) => {
75-
'worklet';
7674
// when bottom sheet is not fully opened scroll offset should not influence
7775
// its position (prevents random snapping when opening bottom sheet when
7876
// the content is already scrolled)
@@ -93,7 +91,6 @@ function Example() {
9391

9492
const headerGesture = usePanGesture({
9593
onUpdate: (e) => {
96-
'worklet';
9794
translationY.value = e.translationY;
9895
},
9996
onDeactivate: onHandlerDeactivate,

0 commit comments

Comments
 (0)