Skip to content
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

Add additional event API responder surfaces #15248

Merged
merged 3 commits into from
Mar 29, 2019

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Mar 29, 2019

Note: this is for an experimental event API that we're testing out internally at Facebook.

This PR adds more event responder surfaces, fills in the TODOs around the responder ownership model and also fixes some bugs found with internal user testing.

@sizebot
Copy link

sizebot commented Mar 29, 2019

ReactDOM: size: 0.0%, gzip: 0.0%

Details of bundled changes.

Comparing: 700f17b...6557cfa

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.1% +0.1% 812.99 KB 813.58 KB 184.13 KB 184.23 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 105.12 KB 105.12 KB 33.97 KB 33.97 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 108.09 KB 108.1 KB 34.63 KB 34.63 KB UMD_PROFILING
react-dom.development.js +0.1% +0.1% 807.38 KB 807.97 KB 182.53 KB 182.63 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 105.09 KB 105.1 KB 33.47 KB 33.48 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 108.19 KB 108.2 KB 34.08 KB 34.08 KB NODE_PROFILING
ReactDOM-dev.js +0.1% +0.1% 832.07 KB 832.65 KB 184.16 KB 184.25 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.2% 🔺+0.2% 330.82 KB 331.38 KB 60.93 KB 61.04 KB FB_WWW_PROD
ReactDOM-profiling.js +0.2% +0.2% 337.2 KB 337.76 KB 62.29 KB 62.39 KB FB_WWW_PROFILING
react-dom-unstable-fire.development.js +0.1% +0.1% 813.34 KB 813.92 KB 184.28 KB 184.38 KB UMD_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 105.13 KB 105.14 KB 33.98 KB 33.98 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 108.11 KB 108.12 KB 34.64 KB 34.64 KB UMD_PROFILING
react-dom-unstable-fire.development.js +0.1% +0.1% 807.73 KB 808.31 KB 182.67 KB 182.77 KB NODE_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 105.11 KB 105.11 KB 33.48 KB 33.49 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 108.21 KB 108.22 KB 34.09 KB 34.09 KB NODE_PROFILING
ReactFire-dev.js +0.1% +0.1% 831.28 KB 831.86 KB 184.08 KB 184.18 KB FB_WWW_DEV
ReactFire-prod.js 🔺+0.2% 🔺+0.2% 319.48 KB 320.04 KB 58.62 KB 58.71 KB FB_WWW_PROD
ReactFire-profiling.js +0.2% +0.2% 325.81 KB 326.37 KB 59.97 KB 60.06 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.69 KB 10.69 KB 3.67 KB 3.67 KB UMD_PROD
ReactDOMServer-prod.js 0.0% 0.0% 46.19 KB 46.19 KB 10.62 KB 10.63 KB FB_WWW_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.66 KB 3.66 KB 1.45 KB 1.45 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.21 KB 1.21 KB 705 B 706 B UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1.05 KB 1.05 KB 636 B 637 B NODE_PROD

react-events

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-events.development.js 0.0% -0.2% 1.16 KB 1.16 KB 617 B 616 B UMD_DEV
react-events.production.min.js 0.0% 🔺+0.2% 682 B 682 B 430 B 431 B UMD_PROD
react-events-press.development.js +0.3% -0.1% 9.53 KB 9.56 KB 2.4 KB 2.4 KB UMD_DEV
react-events-press.production.min.js 🔺+0.7% -0.1% 3.93 KB 3.96 KB 1.39 KB 1.39 KB UMD_PROD
react-events-press.development.js +0.3% -0.0% 9.36 KB 9.39 KB 2.36 KB 2.36 KB NODE_DEV
react-events-press.production.min.js 🔺+0.7% 🔺+0.1% 3.77 KB 3.8 KB 1.34 KB 1.34 KB NODE_PROD
ReactEventsPress-dev.js +0.3% 0.0% 9.5 KB 9.53 KB 2.37 KB 2.37 KB FB_WWW_DEV
ReactEventsPress-prod.js 🔺+0.3% 0.0% 7.65 KB 7.67 KB 1.71 KB 1.71 KB FB_WWW_PROD
react-events-hover.production.min.js 0.0% 🔺+0.1% 1.95 KB 1.95 KB 844 B 845 B NODE_PROD
react-events-focus.development.js n/a n/a 0 B 2.95 KB 0 B 1.02 KB UMD_DEV
react-events-focus.production.min.js n/a n/a 0 B 1.39 KB 0 B 676 B UMD_PROD
react-events-focus.development.js n/a n/a 0 B 2.78 KB 0 B 992 B NODE_DEV
react-events-focus.production.min.js n/a n/a 0 B 1.22 KB 0 B 613 B NODE_PROD
ReactEventsFocus-dev.js n/a n/a 0 B 2.76 KB 0 B 976 B FB_WWW_DEV
ReactEventsFocus-prod.js n/a n/a 0 B 2.12 KB 0 B 736 B FB_WWW_PROD
react-events-swipe.development.js n/a n/a 0 B 5.98 KB 0 B 1.72 KB UMD_DEV
react-events-swipe.production.min.js n/a n/a 0 B 2.59 KB 0 B 1.15 KB UMD_PROD
react-events-swipe.development.js n/a n/a 0 B 5.81 KB 0 B 1.68 KB NODE_DEV
react-events-swipe.production.min.js n/a n/a 0 B 2.43 KB 0 B 1.09 KB NODE_PROD
ReactEventsSwipe-dev.js n/a n/a 0 B 5.94 KB 0 B 1.7 KB FB_WWW_DEV
ReactEventsSwipe-prod.js n/a n/a 0 B 5.71 KB 0 B 1.43 KB FB_WWW_PROD
react-events-drag.development.js n/a n/a 0 B 5.27 KB 0 B 1.57 KB UMD_DEV
react-events-drag.production.min.js n/a n/a 0 B 2.33 KB 0 B 1 KB UMD_PROD
react-events-drag.development.js n/a n/a 0 B 5.1 KB 0 B 1.53 KB NODE_DEV
react-events-drag.production.min.js n/a n/a 0 B 2.17 KB 0 B 972 B NODE_PROD
ReactEventsDrag-dev.js n/a n/a 0 B 5.28 KB 0 B 1.57 KB FB_WWW_DEV
ReactEventsDrag-prod.js n/a n/a 0 B 4.83 KB 0 B 1.24 KB FB_WWW_PROD

Generated by 🚫 dangerJS

@trueadm trueadm changed the title Add more primitive event API responder modules Add more event API responder surfaces Mar 29, 2019
@trueadm trueadm changed the title Add more event API responder surfaces Add additional event API responder surfaces Mar 29, 2019
@philipp-spiess
Copy link
Contributor

👀 I really like how this is shaping up.

import {REACT_EVENT_COMPONENT_TYPE} from 'shared/ReactSymbols';

const targetEventTypes = ['pointerdown', 'pointercancel'];
const rootEventTypes = ['pointerup', {name: 'pointermove', passive: false}];
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could document why certain events are not passive throughout these event module implementations.

listener: (e: Object) => void,
state: DragState,
discrete: boolean,
eventData?: {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should figure out the event shapes we want for these events. Drag will probably need the delta, coordinates in space, offset from initial position, and velocity.


if (
props.onShouldClaimOwnership &&
props.onShouldClaimOwnership()
Copy link
Contributor

Choose a reason for hiding this comment

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

This prop name doesn't seem quite right. In the RN responder system there are onStartShouldSetResponder and onMoveShouldSetResponder props to determine whether the view wants to become the responder after a start or move event.

}
break;
}
case 'pointercancel':
Copy link
Contributor

Choose a reason for hiding this comment

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

we might eventually want a separate event to be called if the drag is cancelled

import {REACT_EVENT_COMPONENT_TYPE} from 'shared/ReactSymbols';

const targetEventTypes = [
{name: 'focus', passive: true, capture: true},
Copy link
Contributor

Choose a reason for hiding this comment

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

curious why these need to be passive and capture

if (props.onSwipeLeft && direction === 3) {
dispatchSwipeEvent(
context,
'swipeleft',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be preferable to have a single event like onSwipe with event data that provides the direction, velocity, etc. That would be simpler to work with in userland than potentially listening to 4 events.

@trueadm trueadm merged commit a41b217 into facebook:master Mar 29, 2019
@trueadm trueadm deleted the add-other-event-modules branch March 29, 2019 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants