51 lines
1.9 KiB
JavaScript
51 lines
1.9 KiB
JavaScript
|
/**
|
||
|
* Stores result from supportsCssVariables to avoid redundant processing to
|
||
|
* detect CSS custom variable support.
|
||
|
*/
|
||
|
var supportsCssVariables_;
|
||
|
export function supportsCssVariables(windowObj, forceRefresh) {
|
||
|
if (forceRefresh === void 0) { forceRefresh = false; }
|
||
|
var CSS = windowObj.CSS;
|
||
|
var supportsCssVars = supportsCssVariables_;
|
||
|
if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
|
||
|
return supportsCssVariables_;
|
||
|
}
|
||
|
var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
|
||
|
if (!supportsFunctionPresent) {
|
||
|
return false;
|
||
|
}
|
||
|
var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
|
||
|
// See: https://bugs.webkit.org/show_bug.cgi?id=154669
|
||
|
// See: README section on Safari
|
||
|
var weAreFeatureDetectingSafari10plus = (CSS.supports('(--css-vars: yes)') &&
|
||
|
CSS.supports('color', '#00000000'));
|
||
|
supportsCssVars =
|
||
|
explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
|
||
|
if (!forceRefresh) {
|
||
|
supportsCssVariables_ = supportsCssVars;
|
||
|
}
|
||
|
return supportsCssVars;
|
||
|
}
|
||
|
export function getNormalizedEventCoords(evt, pageOffset, clientRect) {
|
||
|
if (!evt) {
|
||
|
return { x: 0, y: 0 };
|
||
|
}
|
||
|
var x = pageOffset.x, y = pageOffset.y;
|
||
|
var documentX = x + clientRect.left;
|
||
|
var documentY = y + clientRect.top;
|
||
|
var normalizedX;
|
||
|
var normalizedY;
|
||
|
// Determine touch point relative to the ripple container.
|
||
|
if (evt.type === 'touchstart') {
|
||
|
var touchEvent = evt;
|
||
|
normalizedX = touchEvent.changedTouches[0].pageX - documentX;
|
||
|
normalizedY = touchEvent.changedTouches[0].pageY - documentY;
|
||
|
}
|
||
|
else {
|
||
|
var mouseEvent = evt;
|
||
|
normalizedX = mouseEvent.pageX - documentX;
|
||
|
normalizedY = mouseEvent.pageY - documentY;
|
||
|
}
|
||
|
return { x: normalizedX, y: normalizedY };
|
||
|
}
|
||
|
//# sourceMappingURL=util.js.map
|