UNPKG

1.91 kBJavaScriptView Raw
1/**
2 * Stores result from supportsCssVariables to avoid redundant processing to
3 * detect CSS custom variable support.
4 */
5var supportsCssVariables_;
6export function supportsCssVariables(windowObj, forceRefresh) {
7 if (forceRefresh === void 0) { forceRefresh = false; }
8 var CSS = windowObj.CSS;
9 var supportsCssVars = supportsCssVariables_;
10 if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
11 return supportsCssVariables_;
12 }
13 var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
14 if (!supportsFunctionPresent) {
15 return false;
16 }
17 var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
18 // See: https://bugs.webkit.org/show_bug.cgi?id=154669
19 // See: README section on Safari
20 var weAreFeatureDetectingSafari10plus = (CSS.supports('(--css-vars: yes)') &&
21 CSS.supports('color', '#00000000'));
22 supportsCssVars =
23 explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
24 if (!forceRefresh) {
25 supportsCssVariables_ = supportsCssVars;
26 }
27 return supportsCssVars;
28}
29export function getNormalizedEventCoords(evt, pageOffset, clientRect) {
30 if (!evt) {
31 return { x: 0, y: 0 };
32 }
33 var x = pageOffset.x, y = pageOffset.y;
34 var documentX = x + clientRect.left;
35 var documentY = y + clientRect.top;
36 var normalizedX;
37 var normalizedY;
38 // Determine touch point relative to the ripple container.
39 if (evt.type === 'touchstart') {
40 var touchEvent = evt;
41 normalizedX = touchEvent.changedTouches[0].pageX - documentX;
42 normalizedY = touchEvent.changedTouches[0].pageY - documentY;
43 }
44 else {
45 var mouseEvent = evt;
46 normalizedX = mouseEvent.pageX - documentX;
47 normalizedY = mouseEvent.pageY - documentY;
48 }
49 return { x: normalizedX, y: normalizedY };
50}
51//# sourceMappingURL=util.js.map
\No newline at end of file