1 |
|
2 |
|
3 |
|
4 |
|
5 | var supportsCssVariables_;
|
6 | export 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 |
|
19 |
|
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 | }
|
29 | export 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 |
|
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 |
|
\ | No newline at end of file |