UNPKG

@angular/cdk

Version:

Angular Material Component Development Kit

59 lines (57 loc) 2.25 kB
var RtlScrollAxisType; (function (RtlScrollAxisType) { RtlScrollAxisType[RtlScrollAxisType["NORMAL"] = 0] = "NORMAL"; RtlScrollAxisType[RtlScrollAxisType["NEGATED"] = 1] = "NEGATED"; RtlScrollAxisType[RtlScrollAxisType["INVERTED"] = 2] = "INVERTED"; })(RtlScrollAxisType || (RtlScrollAxisType = {})); let rtlScrollAxisType; let scrollBehaviorSupported; function supportsScrollBehavior() { if (scrollBehaviorSupported == null) { if (typeof document !== 'object' || !document || typeof Element !== 'function' || !Element) { scrollBehaviorSupported = false; return scrollBehaviorSupported; } if (document.documentElement?.style && 'scrollBehavior' in document.documentElement.style) { scrollBehaviorSupported = true; } else { const scrollToFunction = Element.prototype.scrollTo; if (scrollToFunction) { scrollBehaviorSupported = !/\{\s*\[native code\]\s*\}/.test(scrollToFunction.toString()); } else { scrollBehaviorSupported = false; } } } return scrollBehaviorSupported; } function getRtlScrollAxisType() { if (typeof document !== 'object' || !document) { return RtlScrollAxisType.NORMAL; } if (rtlScrollAxisType == null) { const scrollContainer = document.createElement('div'); const containerStyle = scrollContainer.style; scrollContainer.dir = 'rtl'; containerStyle.width = '1px'; containerStyle.overflow = 'auto'; containerStyle.visibility = 'hidden'; containerStyle.pointerEvents = 'none'; containerStyle.position = 'absolute'; const content = document.createElement('div'); const contentStyle = content.style; contentStyle.width = '2px'; contentStyle.height = '1px'; scrollContainer.appendChild(content); document.body.appendChild(scrollContainer); rtlScrollAxisType = RtlScrollAxisType.NORMAL; if (scrollContainer.scrollLeft === 0) { scrollContainer.scrollLeft = 1; rtlScrollAxisType = scrollContainer.scrollLeft === 0 ? RtlScrollAxisType.NEGATED : RtlScrollAxisType.INVERTED; } scrollContainer.remove(); } return rtlScrollAxisType; } export { RtlScrollAxisType, getRtlScrollAxisType, supportsScrollBehavior }; //# sourceMappingURL=_scrolling-chunk.mjs.map