UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

36 lines (35 loc) 1.87 kB
import { Info, Warn, Error } from "./logging.mjs"; let isTouchDevice = "ontouchstart" in document.documentElement || document.ontouchstart !== void 0 || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; window.addEventListener("touchstart", function onFirstTouch() { isTouchDevice = true; window.removeEventListener("touchstart", onFirstTouch, false); }, false); let _supportsCursorURIs = false; try { const target = document.createElement("canvas"); target.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default'; if (target.style.cursor.indexOf("url") === 0) { Info("Data URI scheme cursor supported"); _supportsCursorURIs = true; } else { Warn("Data URI scheme cursor not supported"); } } catch (exc) { Error("Data URI scheme cursor test exception: " + exc); } let _hasScrollbarGutter = true; try { const container = document.createElement("div"); container.style.visibility = "hidden"; container.style.overflow = "scroll"; document.body.appendChild(container); const child = document.createElement("div"); container.appendChild(child); const scrollbarWidth = container.offsetWidth - child.offsetWidth; container.parentNode.removeChild(container); _hasScrollbarGutter = scrollbarWidth != 0; } catch (exc) { Error("Scrollbar test exception: " + exc); } const hasScrollbarGutter = _hasScrollbarGutter; export { hasScrollbarGutter, isTouchDevice };