From 7485208498939378d5756dbf0adcfce930896e7e Mon Sep 17 00:00:00 2001 From: simek Date: Tue, 15 Dec 2020 11:48:00 -0800 Subject: [PATCH] Pressability: fix typo in variable, follow event check pattern, small tweak (#30151) Summary: This small PR introduces the following changes to the `Pressability`: * fixes typo in internal `isActivationTransiton` variable name * assigns `onPressMove` to variable before check and potential usage (this is the common pattern in this file) * utilizes destructuring assignment to simplify passing coordinates to `_touchActivatePosition` ## Changelog [Internal] [Fixed] - Pressability: fix typo in variable, follow event check pattern, small tweak Pull Request resolved: https://github.com/facebook/react-native/pull/30151 Test Plan: Successful `yarn test` run. Reviewed By: kacieb Differential Revision: D25545662 Pulled By: nadiia fbshipit-source-id: 8d311fe21b485ee707e05dad120322b3027e686b --- Libraries/Pressability/Pressability.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Libraries/Pressability/Pressability.js b/Libraries/Pressability/Pressability.js index ba6ba885dff..17dae80c59c 100644 --- a/Libraries/Pressability/Pressability.js +++ b/Libraries/Pressability/Pressability.js @@ -491,8 +491,9 @@ export default class Pressability { }, onResponderMove: (event: PressEvent): void => { - if (this._config.onPressMove != null) { - this._config.onPressMove(event); + const {onPressMove} = this._config; + if (onPressMove != null) { + onPressMove(event); } // Region may not have finished being measured, yet. @@ -655,10 +656,10 @@ export default class Pressability { prevState === 'NOT_RESPONDER' && nextState === 'RESPONDER_INACTIVE_PRESS_IN'; - const isActivationTransiton = + const isActivationTransition = !isActivationSignal(prevState) && isActivationSignal(nextState); - if (isInitialTransition || isActivationTransiton) { + if (isInitialTransition || isActivationTransition) { this._measureResponderRegion(); } @@ -704,11 +705,8 @@ export default class Pressability { _activate(event: PressEvent): void { const {onPressIn} = this._config; - const touch = getTouchFromPressEvent(event); - this._touchActivatePosition = { - pageX: touch.pageX, - pageY: touch.pageY, - }; + const {pageX, pageY} = getTouchFromPressEvent(event); + this._touchActivatePosition = {pageX, pageY}; this._touchActivateTime = Date.now(); if (onPressIn != null) { onPressIn(event);