UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

94 lines (93 loc) 2.94 kB
/** * DevExtreme (esm/__internal/core/utils/m_support.js) * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import devices from "../../../common/core/environment/devices"; import domAdapter from "../../../core/dom_adapter"; import callOnce from "../../../core/utils/call_once"; import { styleProp, stylePropPrefix } from "../../../core/utils/style"; import { getNavigator, hasProperty } from "../../../core/utils/window"; const { maxTouchPoints: maxTouchPoints } = getNavigator(); const transitionEndEventNames = { webkitTransition: "webkitTransitionEnd", MozTransition: "transitionend", OTransition: "oTransitionEnd", transition: "transitionend" }; const supportProp = function(prop) { return !!styleProp(prop) }; const isNativeScrollingSupported = function() { const { platform: platform, mac: isMac } = devices.real(); const isNativeScrollDevice = "ios" === platform || "android" === platform || isMac; return isNativeScrollDevice }; const inputType = function(type) { if ("text" === type) { return true } const input = domAdapter.createElement("input"); try { input.setAttribute("type", type); input.value = "wrongValue"; return !input.value } catch (e) { return false } }; const detectTouchEvents = function(hasWindowProperty, maxTouchPoints) { return (hasWindowProperty("ontouchstart") || !!maxTouchPoints) && !hasWindowProperty("callPhantom") }; const detectPointerEvent = function(hasWindowProperty) { return hasWindowProperty("PointerEvent") }; const touchEvents = detectTouchEvents(hasProperty, maxTouchPoints); const pointerEvents = detectPointerEvent(hasProperty); const touchPointersPresent = !!maxTouchPoints; export { inputType, pointerEvents, styleProp, stylePropPrefix, supportProp, touchEvents }; export const touch = touchEvents || pointerEvents && touchPointersPresent; export const transition = callOnce((function() { return supportProp("transition") })); export const transitionEndEventName = callOnce((function() { return transitionEndEventNames[styleProp("transition")] })); export const animation = callOnce((function() { return supportProp("animation") })); export const nativeScrolling = isNativeScrollingSupported(); export default { animation: animation, inputType: inputType, nativeScrolling: nativeScrolling, pointerEvents: pointerEvents, styleProp: styleProp, stylePropPrefix: stylePropPrefix, supportProp: supportProp, touch: touch, touchEvents: touchEvents, transition: transition, transitionEndEventName: transitionEndEventName };