Skip to content

Commit a6dda42

Browse files
committed
Merge branch 'main' into @mbert/remove-pointer-tracker-casts
2 parents 48d880e + 36d302e commit a6dda42

File tree

4 files changed

+46
-83
lines changed

4 files changed

+46
-83
lines changed

.github/workflows/needs-repro.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Check for reproduction
33
on:
44
issues:
55
types: [opened, edited]
6-
issue_comment:
7-
types: [created, edited, deleted]
86

97
jobs:
108
main:

packages/react-native-gesture-handler/android/src/main/jni/CMakeLists.txt

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,10 @@ target_include_directories(
2727

2828
find_package(ReactAndroid REQUIRED CONFIG)
2929
find_package(fbjni REQUIRED CONFIG)
30-
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
31-
find_package(fbjni REQUIRED CONFIG)
32-
target_link_libraries(
33-
${PACKAGE_NAME}
34-
ReactAndroid::reactnative
35-
ReactAndroid::jsi
36-
fbjni::fbjni
37-
)
38-
elseif (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
39-
target_link_libraries(
40-
${PACKAGE_NAME}
41-
ReactAndroid::reactnative
42-
ReactAndroid::jsi
43-
)
44-
elseif (ReactAndroid_VERSION_MINOR GREATER_EQUAL 75)
45-
target_link_libraries(
46-
${PACKAGE_NAME}
47-
ReactAndroid::react_render_core
48-
ReactAndroid::react_render_uimanager
49-
ReactAndroid::react_render_graphics
50-
ReactAndroid::jsi
51-
ReactAndroid::react_nativemodule_core
52-
)
53-
else ()
54-
message(FATAL_ERROR "react-native-gesture-handler on the New Architecture requires react-native 0.75 or newer.")
55-
endif ()
30+
31+
target_link_libraries(
32+
${PACKAGE_NAME}
33+
ReactAndroid::reactnative
34+
ReactAndroid::jsi
35+
fbjni::fbjni
36+
)

packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,20 @@ export default class PanGestureHandler extends GestureHandler {
218218
clearTimeout(this.activationTimeout);
219219
}
220220

221+
private updateLastCoords() {
222+
const { x, y } = this.tracker.getAbsoluteCoordsAverage();
223+
224+
this.lastX = x;
225+
this.lastY = y;
226+
}
227+
228+
private updateVelocity(pointerId: number) {
229+
const velocities = this.tracker.getVelocity(pointerId);
230+
231+
this.velocityX = velocities?.x ?? 0;
232+
this.velocityY = velocities?.y ?? 0;
233+
}
234+
221235
// Events Handling
222236
protected onPointerDown(event: AdaptedEvent): void {
223237
if (!this.isButtonInConfig(event.button)) {
@@ -229,9 +243,7 @@ export default class PanGestureHandler extends GestureHandler {
229243

230244
super.onPointerDown(event);
231245

232-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
233-
this.lastX = lastCoords.x;
234-
this.lastY = lastCoords.y;
246+
this.updateLastCoords();
235247

236248
this.startX = this.lastX;
237249
this.startY = this.lastY;
@@ -250,9 +262,7 @@ export default class PanGestureHandler extends GestureHandler {
250262
this.offsetX += this.lastX - this.startX;
251263
this.offsetY += this.lastY - this.startY;
252264

253-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
254-
this.lastX = lastCoords.x;
255-
this.lastY = lastCoords.y;
265+
this.updateLastCoords();
256266

257267
this.startX = this.lastX;
258268
this.startY = this.lastY;
@@ -299,9 +309,7 @@ export default class PanGestureHandler extends GestureHandler {
299309
this.offsetX += this.lastX - this.startX;
300310
this.offsetY += this.lastY - this.startY;
301311

302-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
303-
this.lastX = lastCoords.x;
304-
this.lastY = lastCoords.y;
312+
this.updateLastCoords();
305313

306314
this.startX = this.lastX;
307315
this.startY = this.lastY;
@@ -320,13 +328,8 @@ export default class PanGestureHandler extends GestureHandler {
320328
this.tracker.track(event);
321329
this.stylusData = event.stylusData;
322330

323-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
324-
this.lastX = lastCoords.x;
325-
this.lastY = lastCoords.y;
326-
327-
const velocity = this.tracker.getVelocity(event.pointerId);
328-
this.velocityX = velocity?.x ?? 0;
329-
this.velocityY = velocity?.y ?? 0;
331+
this.updateLastCoords();
332+
this.updateVelocity(event.pointerId);
330333

331334
this.checkBegan();
332335

@@ -341,13 +344,8 @@ export default class PanGestureHandler extends GestureHandler {
341344
this.tracker.track(event);
342345
this.stylusData = event.stylusData;
343346

344-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
345-
this.lastX = lastCoords.x;
346-
this.lastY = lastCoords.y;
347-
348-
const velocity = this.tracker.getVelocity(event.pointerId);
349-
this.velocityX = velocity?.x ?? 0;
350-
this.velocityY = velocity?.y ?? 0;
347+
this.updateLastCoords();
348+
this.updateVelocity(event.pointerId);
351349

352350
this.checkBegan();
353351

@@ -391,9 +389,7 @@ export default class PanGestureHandler extends GestureHandler {
391389

392390
this.tracker.addToTracker(event);
393391

394-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
395-
this.lastX = lastCoords.x;
396-
this.lastY = lastCoords.y;
392+
this.updateLastCoords();
397393

398394
this.startX = this.lastX;
399395
this.startY = this.lastY;
@@ -403,13 +399,8 @@ export default class PanGestureHandler extends GestureHandler {
403399
}
404400
this.tracker.track(event);
405401

406-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
407-
this.lastX = lastCoords.x;
408-
this.lastY = lastCoords.y;
409-
410-
const velocity = this.tracker.getVelocity(event.pointerId);
411-
this.velocityX = velocity?.x ?? 0;
412-
this.velocityY = velocity?.y ?? 0;
402+
this.updateLastCoords();
403+
this.updateVelocity(event.pointerId);
413404

414405
this.tryToSendMoveEvent(false, event);
415406
this.scheduleWheelEnd(event);
@@ -540,9 +531,7 @@ export default class PanGestureHandler extends GestureHandler {
540531
}, this.activateAfterLongPress);
541532
}
542533
} else {
543-
const velocity = this.tracker.getVelocity(event.pointerId);
544-
this.velocityX = velocity?.x ?? 0;
545-
this.velocityY = velocity?.y ?? 0;
534+
this.updateVelocity(event.pointerId);
546535
}
547536
}
548537

packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ export default class TapGestureHandler extends GestureHandler {
9999
}
100100
}
101101

102+
private updateLastCoords() {
103+
const { x, y } = this.tracker.getAbsoluteCoordsAverage();
104+
105+
this.lastX = x;
106+
this.lastY = y;
107+
}
108+
102109
// Handling Events
103110
protected onPointerDown(event: AdaptedEvent): void {
104111
if (!this.isButtonInConfig(event.button)) {
@@ -129,22 +136,18 @@ export default class TapGestureHandler extends GestureHandler {
129136
this.offsetX += this.lastX - this.startX;
130137
this.offsetY += this.lastY - this.startY;
131138

132-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
133-
this.lastX = lastCoords.x;
134-
this.lastY = lastCoords.y;
139+
this.updateLastCoords();
135140

136-
this.startX = lastCoords.x;
137-
this.startY = lastCoords.y;
141+
this.startX = this.lastX;
142+
this.startY = this.lastY;
138143

139144
this.updateState(event);
140145
}
141146

142147
protected onPointerUp(event: AdaptedEvent): void {
143148
super.onPointerUp(event);
144149

145-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
146-
this.lastX = lastCoords.x;
147-
this.lastY = lastCoords.y;
150+
this.updateLastCoords();
148151

149152
this.tracker.removeFromTracker(event.pointerId);
150153

@@ -158,9 +161,7 @@ export default class TapGestureHandler extends GestureHandler {
158161
this.offsetX += this.lastX - this.startX;
159162
this.offsetY += this.lastY = this.startY;
160163

161-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
162-
this.lastX = lastCoords.x;
163-
this.lastY = lastCoords.y;
164+
this.updateLastCoords();
164165

165166
this.startX = this.lastX;
166167
this.startY = this.lastY;
@@ -172,10 +173,7 @@ export default class TapGestureHandler extends GestureHandler {
172173
this.trySettingPosition(event);
173174
this.tracker.track(event);
174175

175-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
176-
this.lastX = lastCoords.x;
177-
this.lastY = lastCoords.y;
178-
176+
this.updateLastCoords();
179177
this.updateState(event);
180178

181179
super.onPointerMove(event);
@@ -185,10 +183,7 @@ export default class TapGestureHandler extends GestureHandler {
185183
this.trySettingPosition(event);
186184
this.tracker.track(event);
187185

188-
const lastCoords = this.tracker.getAbsoluteCoordsAverage();
189-
this.lastX = lastCoords.x;
190-
this.lastY = lastCoords.y;
191-
186+
this.updateLastCoords();
192187
this.updateState(event);
193188

194189
super.onPointerOutOfBounds(event);

0 commit comments

Comments
 (0)