Skip to content

[Web] Bind SharedValues in handler config #3673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: @mbert/shared-values
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}

// @ts-ignore Types should be HTMLElement or React.Component
NodeManager.getHandler(handlerTag).init(newView, propsRef, actionType);

Check warning on line 66 in packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts

View workflow job for this annotation

GitHub Actions / check

Unsafe call of an `any` typed value
},
detachGestureHandler(handlerTag: number) {
if (shouldPreventDrop) {
Expand All @@ -74,15 +74,15 @@
NodeManager.detachGestureHandler(handlerTag);
},
setGestureHandlerConfig(handlerTag: number, newConfig: Config) {
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
NodeManager.getHandler(handlerTag).setGestureConfig(newConfig);

InteractionManager.instance.configureInteractions(
NodeManager.getHandler(handlerTag),
newConfig
);
},
updateGestureHandlerConfig(_handlerTag: number, _newConfig: Config) {
// TODO: To be implemented
updateGestureHandlerConfig(handlerTag: number, newConfig: Config) {
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
},
getGestureHandlerNode(handlerTag: number) {
return NodeManager.getHandler(handlerTag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,11 @@ export default abstract class GestureHandler implements IGestureHandler {
// Handling config
//

public setGestureConfig(config: Config) {
this.resetConfig();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that shouldCancelWhenOutside is set to default value on Android, while here it is not. Could we check which fields should be reset in this method, as now it is only overriden in child classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my bad did not notice it was not implemented. Fixed in 4fd97f8a1b8. I included dispatchesAnimatedEvent there, I'm not sure what the correct default value for mouseButton, but from what I see android default 0 is used as undefined so I put undefined. Also, different fields are reset on Android and different on iOS. It seems weird, I'll have to look into whether or not reset iOS fields as well. For now I'm mimicking android

this.updateGestureConfig(config);
}

public updateGestureConfig({
enabled = true,
dispatchesAnimatedEvents = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default interface IGestureHandler {

sendEvent: (newState: State, oldState: State) => void;

setGestureConfig: (config: Config) => void;
updateGestureConfig: (config: Config) => void;

isButton?: () => boolean;
Expand Down
Loading