Skip to content

Commit 32c360e

Browse files
authored
Remove all Hammer.JS usages & references (#3229)
## Description <!-- Description and motivation for this PR. Include 'Fixes #<number>' if this is fixing some issue. --> Removed legacy `Hammer.JS` web implementation, all it's usages and references. Removed `enableLegacyWebImplementation`. Removed `isNewWebImplementationEnabled`. It's not abundantly clear at first, but it's an internal function. ## Test plan
1 parent 3daca2d commit 32c360e

28 files changed

+27
-1905
lines changed

FabricExample/yarn.lock

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,13 +1128,6 @@
11281128
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
11291129
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
11301130

1131-
"@egjs/hammerjs@^2.0.17":
1132-
version "2.0.17"
1133-
resolved "https://registry.yarnpkg.com/@egjs/hammerjs/-/hammerjs-2.0.17.tgz#5dc02af75a6a06e4c2db0202cae38c9263895124"
1134-
integrity sha512-XQsZgjm2EcVUiZQf11UBJQfmZeEmOW8DpI1gsFeln6w0ae0ii4dMQEQ0kjl6DspdWX1aGY1/loyXnP0JS06e/A==
1135-
dependencies:
1136-
"@types/hammerjs" "^2.0.36"
1137-
11381131
"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
11391132
version "4.4.0"
11401133
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
@@ -1902,11 +1895,6 @@
19021895
dependencies:
19031896
"@types/node" "*"
19041897

1905-
"@types/hammerjs@^2.0.36":
1906-
version "2.0.45"
1907-
resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.45.tgz#ffa764bb68a66c08db6efb9c816eb7be850577b1"
1908-
integrity sha512-qkcUlZmX6c4J8q45taBKTL3p+LbITgyx7qhlPYOdOHZB7B31K0mXbP5YA7i7SgDeEGuI9MnumiKPEMrxg8j3KQ==
1909-
19101898
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
19111899
version "2.0.6"
19121900
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7"

MacOSExample/yarn.lock

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,13 +1427,6 @@
14271427
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
14281428
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
14291429

1430-
"@egjs/hammerjs@^2.0.17":
1431-
version "2.0.17"
1432-
resolved "https://registry.yarnpkg.com/@egjs/hammerjs/-/hammerjs-2.0.17.tgz#5dc02af75a6a06e4c2db0202cae38c9263895124"
1433-
integrity sha512-XQsZgjm2EcVUiZQf11UBJQfmZeEmOW8DpI1gsFeln6w0ae0ii4dMQEQ0kjl6DspdWX1aGY1/loyXnP0JS06e/A==
1434-
dependencies:
1435-
"@types/hammerjs" "^2.0.36"
1436-
14371430
"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
14381431
version "4.4.0"
14391432
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
@@ -2330,11 +2323,6 @@
23302323
dependencies:
23312324
"@types/node" "*"
23322325

2333-
"@types/hammerjs@^2.0.36":
2334-
version "2.0.43"
2335-
resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.43.tgz#8660dd1e0e5fd979395e2f999e670cdb9484d1e9"
2336-
integrity sha512-wqxfwHk83RS7+6OpytGdo5wqkqtvx+bGaIs1Rwm5NrtQHUfL4OgWs/5p0OipmjmT+fexePh37Ek+mqIpdNjQKA==
2337-
23382326
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
23392327
version "2.0.5"
23402328
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz#fdfdd69fa16d530047d9963635bd77c71a08c068"

docs/docs/fundamentals/installation.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,4 @@ import 'react-native-gesture-handler';
193193

194194
## Web
195195

196-
There is no additional configuration required for the web, however, since the Gesture Handler 2.10.0 the new web implementation is enabled by default. It is recommended to check if the gestures in your app are working as expected since their behavior should now resemble the native platforms. If you don't want to use the new implementation, you can still revert back to the legacy one by enabling it at the beginning of your `index.js` file:
197-
198-
```js
199-
import { enableLegacyWebImplementation } from 'react-native-gesture-handler';
200-
201-
enableLegacyWebImplementation(true);
202-
```
203-
204-
Nonetheless, it's recommended to adapt to the new implementation, as the legacy one will be dropped at some point in the future.
205-
206-
If you want to start using the new implementation but don't want to upgrade Gesture Handler, you can enable it (starting with Gesture Handler 2.6.0) at the beginning of your `index.js` file:
207-
208-
```js
209-
import { enableExperimentalWebImplementation } from 'react-native-gesture-handler';
210-
211-
enableExperimentalWebImplementation(true);
212-
```
196+
There is no additional configuration required for the web.

e2e/web-tests/App.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import React from 'react';
22
import { StyleSheet, View } from 'react-native';
3-
import { enableExperimentalWebImplementation } from 'react-native-gesture-handler';
43
import { DoubleTapTest } from './components/DoubleTapTest';
54
import { PanTest } from './components/PanTest';
65
import { TapTest } from './components/TapTest';
76
import { LongPressTest } from './components/LongPressTest';
87

9-
enableExperimentalWebImplementation();
10-
118
export default function App() {
129
return (
1310
<View style={styles.container}>

example/yarn.lock

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,13 +1049,6 @@
10491049
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
10501050
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
10511051

1052-
"@egjs/hammerjs@^2.0.17":
1053-
version "2.0.17"
1054-
resolved "https://registry.yarnpkg.com/@egjs/hammerjs/-/hammerjs-2.0.17.tgz#5dc02af75a6a06e4c2db0202cae38c9263895124"
1055-
integrity sha512-XQsZgjm2EcVUiZQf11UBJQfmZeEmOW8DpI1gsFeln6w0ae0ii4dMQEQ0kjl6DspdWX1aGY1/loyXnP0JS06e/A==
1056-
dependencies:
1057-
"@types/hammerjs" "^2.0.36"
1058-
10591052
"@eslint-community/eslint-utils@^4.2.0":
10601053
version "4.4.0"
10611054
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
@@ -2264,11 +2257,6 @@
22642257
dependencies:
22652258
"@types/node" "*"
22662259

2267-
"@types/hammerjs@^2.0.36":
2268-
version "2.0.45"
2269-
resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.45.tgz#ffa764bb68a66c08db6efb9c816eb7be850577b1"
2270-
integrity sha512-qkcUlZmX6c4J8q45taBKTL3p+LbITgyx7qhlPYOdOHZB7B31K0mXbP5YA7i7SgDeEGuI9MnumiKPEMrxg8j3KQ==
2271-
22722260
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
22732261
version "2.0.6"
22742262
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7"

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
},
6565
"homepage": "https://github.com/software-mansion/react-native-gesture-handler#readme",
6666
"dependencies": {
67-
"@egjs/hammerjs": "^2.0.17",
6867
"hoist-non-react-statics": "^3.3.0",
6968
"invariant": "^2.2.4"
7069
},

src/EnableNewWebImplementation.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/RNGestureHandlerModule.web.ts

Lines changed: 23 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import React from 'react';
22

33
import type { ActionType } from './ActionType';
4-
import { isNewWebImplementationEnabled } from './EnableNewWebImplementation';
5-
import { Gestures, HammerGestures } from './web/Gestures';
4+
import { Gestures } from './web/Gestures';
65
import type { Config } from './web/interfaces';
76
import InteractionManager from './web/tools/InteractionManager';
87
import NodeManager from './web/tools/NodeManager';
9-
import * as HammerNodeManager from './web_hammer/NodeManager';
108
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
119

1210
// init method is called inside attachGestureHandler function. However, this function may
@@ -28,36 +26,21 @@ export default {
2826
handlerTag: number,
2927
config: T
3028
) {
31-
if (isNewWebImplementationEnabled()) {
32-
if (!(handlerName in Gestures)) {
33-
throw new Error(
34-
`react-native-gesture-handler: ${handlerName} is not supported on web.`
35-
);
36-
}
37-
38-
const GestureClass = Gestures[handlerName];
39-
NodeManager.createGestureHandler(
40-
handlerTag,
41-
new GestureClass(new GestureHandlerWebDelegate())
42-
);
43-
InteractionManager.getInstance().configureInteractions(
44-
NodeManager.getHandler(handlerTag),
45-
config as unknown as Config
29+
if (!(handlerName in Gestures)) {
30+
throw new Error(
31+
`react-native-gesture-handler: ${handlerName} is not supported on web.`
4632
);
47-
} else {
48-
if (!(handlerName in HammerGestures)) {
49-
throw new Error(
50-
`react-native-gesture-handler: ${handlerName} is not supported on web.`
51-
);
52-
}
53-
54-
// @ts-ignore If it doesn't exist, the error is thrown
55-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
56-
const GestureClass = HammerGestures[handlerName];
57-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
58-
HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());
5933
}
6034

35+
const GestureClass = Gestures[handlerName];
36+
NodeManager.createGestureHandler(
37+
handlerTag,
38+
new GestureClass(new GestureHandlerWebDelegate())
39+
);
40+
InteractionManager.getInstance().configureInteractions(
41+
NodeManager.getHandler(handlerTag),
42+
config as unknown as Config
43+
);
6144
this.updateGestureHandler(handlerTag, config as unknown as Config);
6245
},
6346
attachGestureHandler(
@@ -70,9 +53,7 @@ export default {
7053
if (!(newView instanceof Element || newView instanceof React.Component)) {
7154
shouldPreventDrop = true;
7255

73-
const handler = isNewWebImplementationEnabled()
74-
? NodeManager.getHandler(handlerTag)
75-
: HammerNodeManager.getHandler(handlerTag);
56+
const handler = NodeManager.getHandler(handlerTag);
7657

7758
const handlerName = handler.constructor.name;
7859

@@ -81,43 +62,26 @@ export default {
8162
);
8263
}
8364

84-
if (isNewWebImplementationEnabled()) {
85-
// @ts-ignore Types should be HTMLElement or React.Component
86-
NodeManager.getHandler(handlerTag).init(newView, propsRef);
87-
} else {
88-
// @ts-ignore Types should be HTMLElement or React.Component
89-
HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);
90-
}
65+
// @ts-ignore Types should be HTMLElement or React.Component
66+
NodeManager.getHandler(handlerTag).init(newView, propsRef);
9167
},
9268
updateGestureHandler(handlerTag: number, newConfig: Config) {
93-
if (isNewWebImplementationEnabled()) {
94-
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
69+
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
9570

96-
InteractionManager.getInstance().configureInteractions(
97-
NodeManager.getHandler(handlerTag),
98-
newConfig
99-
);
100-
} else {
101-
HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
102-
}
71+
InteractionManager.getInstance().configureInteractions(
72+
NodeManager.getHandler(handlerTag),
73+
newConfig
74+
);
10375
},
10476
getGestureHandlerNode(handlerTag: number) {
105-
if (isNewWebImplementationEnabled()) {
106-
return NodeManager.getHandler(handlerTag);
107-
} else {
108-
return HammerNodeManager.getHandler(handlerTag);
109-
}
77+
return NodeManager.getHandler(handlerTag);
11078
},
11179
dropGestureHandler(handlerTag: number) {
11280
if (shouldPreventDrop) {
11381
return;
11482
}
11583

116-
if (isNewWebImplementationEnabled()) {
117-
NodeManager.dropGestureHandler(handlerTag);
118-
} else {
119-
HammerNodeManager.dropGestureHandler(handlerTag);
120-
}
84+
NodeManager.dropGestureHandler(handlerTag);
12185
},
12286
// eslint-disable-next-line @typescript-eslint/no-empty-function
12387
flushOperations() {},

src/handlers/gestures/GestureDetector/utils.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
HandlerStateChangeEvent,
1818
baseGestureHandlerWithDetectorProps,
1919
} from '../../gestureHandlerCommon';
20-
import { isNewWebImplementationEnabled } from '../../../EnableNewWebImplementation';
2120
import { getReactNativeVersion } from '../../../getReactNativeVersion';
2221
import { RNRenderer } from '../../../RNRenderer';
2322
import { useCallback, useRef, useState } from 'react';
@@ -176,10 +175,8 @@ export function useWebEventHandlers() {
176175
onGestureHandlerEvent: (e: HandlerStateChangeEvent<unknown>) => {
177176
onGestureHandlerEvent(e.nativeEvent);
178177
},
179-
onGestureHandlerStateChange: isNewWebImplementationEnabled()
180-
? (e: HandlerStateChangeEvent<unknown>) => {
181-
onGestureHandlerEvent(e.nativeEvent);
182-
}
183-
: undefined,
178+
onGestureHandlerStateChange: (e: HandlerStateChangeEvent<unknown>) => {
179+
onGestureHandlerEvent(e.nativeEvent);
180+
},
184181
});
185182
}

src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,4 @@ export type {
157157
} from './components/DrawerLayout';
158158
export { default as DrawerLayout } from './components/DrawerLayout';
159159

160-
export {
161-
enableExperimentalWebImplementation,
162-
enableLegacyWebImplementation,
163-
} from './EnableNewWebImplementation';
164-
165160
initialize();

0 commit comments

Comments
 (0)