Skip to content

Commit ea0d25b

Browse files
latekvoj-piasecki
authored andcommitted
Remove all Hammer.JS usages & references (#3229)
<!-- 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.
1 parent a80e93d commit ea0d25b

24 files changed

+27
-1885
lines changed

packages/docs-gesture-handler/docs/fundamentals/installation.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,7 @@ cd ios && pod install && cd ..
121121

122122
#### Web
123123

124-
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. We recommend you 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:
125-
126-
```js
127-
import { enableLegacyWebImplementation } from 'react-native-gesture-handler';
128-
129-
enableLegacyWebImplementation(true);
130-
```
131-
132-
Nonetheless, it's recommended to adapt to the new implementation, as the legacy one will be dropped in the next major release of Gesture Handler.
124+
There is no additional configuration required for the web.
133125

134126
#### With [wix/react-native-navigation](https://github.com/wix/react-native-navigation)
135127

packages/react-native-gesture-handler/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
},
7171
"homepage": "https://github.com/software-mansion/react-native-gesture-handler#readme",
7272
"dependencies": {
73-
"@egjs/hammerjs": "^2.0.17",
7473
"hoist-non-react-statics": "^3.3.0",
7574
"invariant": "^2.2.4"
7675
},

packages/react-native-gesture-handler/src/EnableNewWebImplementation.ts

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

packages/react-native-gesture-handler/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.instance.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.instance.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.instance.configureInteractions(
97-
NodeManager.getHandler(handlerTag),
98-
newConfig
99-
);
100-
} else {
101-
HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
102-
}
71+
InteractionManager.instance.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() {},

packages/react-native-gesture-handler/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 { RNRenderer } from '../../../RNRenderer';
2221
import { useCallback, useRef, useState } from 'react';
2322
import { Reanimated } from '../reanimatedWrapper';
@@ -172,10 +171,8 @@ export function useWebEventHandlers() {
172171
onGestureHandlerEvent: (e: HandlerStateChangeEvent<unknown>) => {
173172
onGestureHandlerEvent(e.nativeEvent);
174173
},
175-
onGestureHandlerStateChange: isNewWebImplementationEnabled()
176-
? (e: HandlerStateChangeEvent<unknown>) => {
177-
onGestureHandlerEvent(e.nativeEvent);
178-
}
179-
: undefined,
174+
onGestureHandlerStateChange: (e: HandlerStateChangeEvent<unknown>) => {
175+
onGestureHandlerEvent(e.nativeEvent);
176+
},
180177
});
181178
}

packages/react-native-gesture-handler/src/index.ts

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

164-
export {
165-
enableExperimentalWebImplementation,
166-
enableLegacyWebImplementation,
167-
} from './EnableNewWebImplementation';
168-
169164
initialize();

packages/react-native-gesture-handler/src/web/Gestures.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ import NativeViewGestureHandler from './handlers/NativeViewGestureHandler';
99
import ManualGestureHandler from './handlers/ManualGestureHandler';
1010
import HoverGestureHandler from './handlers/HoverGestureHandler';
1111

12-
// Hammer Handlers
13-
import HammerNativeViewGestureHandler from '../web_hammer/NativeViewGestureHandler';
14-
import HammerPanGestureHandler from '../web_hammer/PanGestureHandler';
15-
import HammerTapGestureHandler from '../web_hammer/TapGestureHandler';
16-
import HammerLongPressGestureHandler from '../web_hammer/LongPressGestureHandler';
17-
import HammerPinchGestureHandler from '../web_hammer/PinchGestureHandler';
18-
import HammerRotationGestureHandler from '../web_hammer/RotationGestureHandler';
19-
import HammerFlingGestureHandler from '../web_hammer/FlingGestureHandler';
20-
2112
export const Gestures = {
2213
NativeViewGestureHandler,
2314
PanGestureHandler,
@@ -29,13 +20,3 @@ export const Gestures = {
2920
ManualGestureHandler,
3021
HoverGestureHandler,
3122
};
32-
33-
export const HammerGestures = {
34-
NativeViewGestureHandler: HammerNativeViewGestureHandler,
35-
PanGestureHandler: HammerPanGestureHandler,
36-
TapGestureHandler: HammerTapGestureHandler,
37-
LongPressGestureHandler: HammerLongPressGestureHandler,
38-
PinchGestureHandler: HammerPinchGestureHandler,
39-
RotationGestureHandler: HammerRotationGestureHandler,
40-
FlingGestureHandler: HammerFlingGestureHandler,
41-
};

packages/react-native-gesture-handler/src/web_hammer/DiscreteGestureHandler.ts

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

packages/react-native-gesture-handler/src/web_hammer/DraggingGestureHandler.ts

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

packages/react-native-gesture-handler/src/web_hammer/Errors.ts

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

0 commit comments

Comments
 (0)