@office-iss/react-native-win32 0.65.1 → 0.65.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +5 -0
- package/CHANGELOG.json +61 -1
- package/CHANGELOG.md +36 -4
- package/Libraries/Components/Pressable/Pressable.win32.js +363 -0
- package/Libraries/Components/View/ReactNativeViewViewConfig.win32.js +1 -0
- package/Libraries/Components/View/Tests/ViewWin32Test.js +48 -3
- package/Libraries/Components/View/View.win32.js +1 -1
- package/Libraries/Components/View/ViewPropTypes.win32.js +544 -0
- package/Libraries/Components/View/ViewWin32.Props.d.ts +1 -0
- package/Libraries/Components/View/ViewWin32.Props.js +1 -1
- package/Libraries/Components/View/ViewWin32.js +8 -6
- package/Libraries/Pressability/HoverState.win32.js +60 -0
- package/Libraries/Pressability/Pressability.win32.js +962 -0
- package/Libraries/Types/CoreEventTypes.win32.js +191 -0
- package/overrides.json +35 -0
- package/package.json +2 -2
- package/src/Libraries/Components/View/Tests/ViewWin32Test.tsx +64 -0
- package/src/Libraries/Components/View/ViewWin32.Props.ts +1 -0
- package/src/Libraries/Components/View/ViewWin32.tsx +7 -5
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import Platform from '../Utilities/Platform';
|
|
12
|
+
|
|
13
|
+
let isEnabled = false;
|
|
14
|
+
|
|
15
|
+
if (Platform.OS === 'web') {
|
|
16
|
+
const canUseDOM = Boolean(
|
|
17
|
+
typeof window !== 'undefined' &&
|
|
18
|
+
window.document &&
|
|
19
|
+
window.document.createElement,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
if (canUseDOM) {
|
|
23
|
+
/**
|
|
24
|
+
* Web browsers emulate mouse events (and hover states) after touch events.
|
|
25
|
+
* This code infers when the currently-in-use modality supports hover
|
|
26
|
+
* (including for multi-modality devices) and considers "hover" to be enabled
|
|
27
|
+
* if a mouse movement occurs more than 1 second after the last touch event.
|
|
28
|
+
* This threshold is long enough to account for longer delays between the
|
|
29
|
+
* browser firing touch and mouse events on low-powered devices.
|
|
30
|
+
*/
|
|
31
|
+
const HOVER_THRESHOLD_MS = 1000;
|
|
32
|
+
let lastTouchTimestamp = 0;
|
|
33
|
+
|
|
34
|
+
const enableHover = () => {
|
|
35
|
+
if (isEnabled || Date.now() - lastTouchTimestamp < HOVER_THRESHOLD_MS) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
isEnabled = true;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const disableHover = () => {
|
|
42
|
+
lastTouchTimestamp = Date.now();
|
|
43
|
+
if (isEnabled) {
|
|
44
|
+
isEnabled = false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
document.addEventListener('touchstart', disableHover, true);
|
|
49
|
+
document.addEventListener('touchmove', disableHover, true);
|
|
50
|
+
document.addEventListener('mousemove', enableHover, true);
|
|
51
|
+
}
|
|
52
|
+
// [Windows
|
|
53
|
+
} else if (Platform.OS === 'windows' || Platform.OS === 'win32') {
|
|
54
|
+
isEnabled = true;
|
|
55
|
+
// Windows]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function isHoverEnabled(): boolean {
|
|
59
|
+
return isEnabled;
|
|
60
|
+
}
|