diff --git a/packages/mui-utils/src/getDisplayName/getDisplayName.ts b/packages/mui-utils/src/getDisplayName/getDisplayName.ts index 5290cabeea2e29..ca1b8a81f18fae 100644 --- a/packages/mui-utils/src/getDisplayName/getDisplayName.ts +++ b/packages/mui-utils/src/getDisplayName/getDisplayName.ts @@ -18,7 +18,7 @@ function getWrappedName(outerType: any, innerType: any, wrapperName: string) { /** * cherry-pick from * https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js - * originally forked from recompose/getDisplayName with added IE11 support + * originally forked from recompose/getDisplayName */ export default function getDisplayName(Component: React.ElementType): string | undefined { if (Component == null) { diff --git a/packages/mui-utils/src/index.ts b/packages/mui-utils/src/index.ts index 44d58f355cd99d..d1bad4da657aef 100644 --- a/packages/mui-utils/src/index.ts +++ b/packages/mui-utils/src/index.ts @@ -29,10 +29,6 @@ export { default as unstable_useTimeout, Timeout as unstable_Timeout } from './u export { default as unstable_useOnMount } from './useOnMount'; export { default as unstable_useIsFocusVisible } from './useIsFocusVisible'; export { default as unstable_getScrollbarSize } from './getScrollbarSize'; -export { - detectScrollType as unstable_detectScrollType, - getNormalizedScrollLeft as unstable_getNormalizedScrollLeft, -} from './scrollLeft'; export { default as usePreviousProps } from './usePreviousProps'; export { default as getValidReactChildren } from './getValidReactChildren'; export { default as visuallyHidden } from './visuallyHidden'; diff --git a/packages/mui-utils/src/scrollLeft/index.ts b/packages/mui-utils/src/scrollLeft/index.ts deleted file mode 100644 index 18abe92db3ac16..00000000000000 --- a/packages/mui-utils/src/scrollLeft/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './scrollLeft'; diff --git a/packages/mui-utils/src/scrollLeft/scrollLeft.d.ts b/packages/mui-utils/src/scrollLeft/scrollLeft.d.ts deleted file mode 100644 index cd6227f302cf45..00000000000000 --- a/packages/mui-utils/src/scrollLeft/scrollLeft.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export function detectScrollType(): string; -export function getNormalizedScrollLeft(element: HTMLElement, direction: string): number; diff --git a/packages/mui-utils/src/scrollLeft/scrollLeft.js b/packages/mui-utils/src/scrollLeft/scrollLeft.js deleted file mode 100644 index e9998373024ca4..00000000000000 --- a/packages/mui-utils/src/scrollLeft/scrollLeft.js +++ /dev/null @@ -1,77 +0,0 @@ -// Source from https://github.com/alitaheri/normalize-scroll-left -let cachedType; - -/** - * Based on the jquery plugin https://github.com/othree/jquery.rtl-scroll-type - * - * Types of scrollLeft, assuming scrollWidth=100 and direction is rtl. - * - * Type | <- Most Left | Most Right -> | Initial - * ---------------- | ------------ | ------------- | ------- - * default | 0 | 100 | 100 - * negative (spec*) | -100 | 0 | 0 - * reverse | 100 | 0 | 0 - * - * Edge 85: default - * Safari 14: negative - * Chrome 85: negative - * Firefox 81: negative - * IE11: reverse - * - * spec* https://drafts.csswg.org/cssom-view/#dom-window-scroll - */ -export function detectScrollType() { - if (cachedType) { - return cachedType; - } - - const dummy = document.createElement('div'); - const container = document.createElement('div'); - container.style.width = '10px'; - container.style.height = '1px'; - dummy.appendChild(container); - dummy.dir = 'rtl'; - dummy.style.fontSize = '14px'; - dummy.style.width = '4px'; - dummy.style.height = '1px'; - dummy.style.position = 'absolute'; - dummy.style.top = '-1000px'; - dummy.style.overflow = 'scroll'; - - document.body.appendChild(dummy); - - cachedType = 'reverse'; - - if (dummy.scrollLeft > 0) { - cachedType = 'default'; - } else { - dummy.scrollLeft = 1; - if (dummy.scrollLeft === 0) { - cachedType = 'negative'; - } - } - - document.body.removeChild(dummy); - return cachedType; -} - -// Based on https://stackoverflow.com/a/24394376 -export function getNormalizedScrollLeft(element, direction) { - const scrollLeft = element.scrollLeft; - - // Perform the calculations only when direction is rtl to avoid messing up the ltr behavior - if (direction !== 'rtl') { - return scrollLeft; - } - - const type = detectScrollType(); - - switch (type) { - case 'negative': - return element.scrollWidth - element.clientWidth + scrollLeft; - case 'reverse': - return element.scrollWidth - element.clientWidth - scrollLeft; - default: - return scrollLeft; - } -}