diff --git a/src/core/environment.ts b/src/core/environment.ts index 72d0f3349..815379b5a 100644 --- a/src/core/environment.ts +++ b/src/core/environment.ts @@ -8,7 +8,7 @@ export const isBrowser = typeof window !== "undefined"; // -100 0 true spec compliant // 0 100 false probably Chrome earlier than v85 // https://github.com/othree/jquery.rtl-scroll-type -export const hasNegativeOffsetInRtl = /*#__PURE__*/ once( +export const hasNegativeOffsetInRTL = /*#__PURE__*/ once( (scrollable: HTMLElement): boolean => { const key = "scrollLeft"; const prev = scrollable[key]; @@ -20,7 +20,7 @@ export const hasNegativeOffsetInRtl = /*#__PURE__*/ once( } ); -export const isRtlDocument = /*#__PURE__*/ once((): boolean => { +export const isRTLDocument = /*#__PURE__*/ once((): boolean => { // TODO support SSR in rtl return isBrowser ? computeStyle(document.body).direction === "rtl" : false; }); diff --git a/src/core/scroller.ts b/src/core/scroller.ts index 8575db488..29afb9a4c 100644 --- a/src/core/scroller.ts +++ b/src/core/scroller.ts @@ -1,4 +1,4 @@ -import { hasNegativeOffsetInRtl, isRtlDocument } from "./environment"; +import { hasNegativeOffsetInRTL, isRTLDocument } from "./environment"; import { ACTION_SCROLL, ACTION_BEFORE_MANUAL_SCROLL, @@ -40,13 +40,13 @@ const createOnWheel = ( }, 50); }; -const normalizeRtlOffset = ( +const normalizeRTLOffset = ( rootElement: HTMLElement, store: VirtualStore, offset: number, diff?: boolean ): number => { - if (hasNegativeOffsetInRtl(rootElement)) { + if (hasNegativeOffsetInRTL(rootElement)) { return -offset; } else { return diff ? -offset : store._getScrollOffsetMax() - offset; @@ -70,8 +70,8 @@ export const createScroller = ( const scrollToKey = isHorizontal ? "scrollLeft" : "scrollTop"; const normalizeOffset = (offset: number, diff?: boolean): number => { - if (isHorizontal && isRtlDocument()) { - return normalizeRtlOffset(rootElement!, store, offset, diff); + if (isHorizontal && isRTLDocument()) { + return normalizeRTLOffset(rootElement!, store, offset, diff); } return offset; }; @@ -203,8 +203,8 @@ export const createWindowScroller = ( const offsetKey = isHorizontal ? "offsetLeft" : "offsetTop"; const normalizeOffset = (offset: number, diff?: boolean): number => { - if (isHorizontal && isRtlDocument()) { - return normalizeRtlOffset(rootElement!, store, offset, diff); + if (isHorizontal && isRTLDocument()) { + return normalizeRTLOffset(rootElement!, store, offset, diff); } return offset; }; @@ -218,7 +218,7 @@ export const createWindowScroller = ( const getOffsetToWindow = (node: HTMLElement, offset: number): number => { const nodeOffset = offset + - (isHorizontal && isRtlDocument() + (isHorizontal && isRTLDocument() ? window.innerWidth - node[offsetKey] - node.offsetWidth : node[offsetKey]); diff --git a/src/react/ListItem.tsx b/src/react/ListItem.tsx index cfabe184f..b40c60271 100644 --- a/src/react/ListItem.tsx +++ b/src/react/ListItem.tsx @@ -11,7 +11,7 @@ import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect"; import { useSelector } from "./useSelector"; import { ListResizer } from "../core/resizer"; import { refKey } from "./utils"; -import { isRtlDocument } from "../core/environment"; +import { isRTLDocument } from "../core/environment"; /** * Props of customized item component for {@link VList}. @@ -68,7 +68,7 @@ export const ListItem = memo( { - const leftOrRightKey = isRtlDocument() ? "right" : "left"; + const leftOrRightKey = isRTLDocument() ? "right" : "left"; const style: CSSProperties = { margin: 0, padding: 0, diff --git a/src/react/VGrid.rtl.spec.tsx b/src/react/VGrid.rtl.spec.tsx index 29ada1bcb..6a0b1d812 100644 --- a/src/react/VGrid.rtl.spec.tsx +++ b/src/react/VGrid.rtl.spec.tsx @@ -6,7 +6,7 @@ jest.mock("../core/environment", () => { const originalModule = jest.requireActual("../core/environment"); return { ...(originalModule as any), - isRtlDocument: () => true, + isRTLDocument: () => true, }; }); diff --git a/src/react/VGrid.tsx b/src/react/VGrid.tsx index c967c8196..157ddaff8 100644 --- a/src/react/VGrid.tsx +++ b/src/react/VGrid.tsx @@ -37,7 +37,7 @@ import { import { createGridResizer, GridResizer } from "../core/resizer"; import { Viewport as DefaultViewport } from "./Viewport"; import { flushSync } from "react-dom"; -import { isRtlDocument } from "../core/environment"; +import { isRTLDocument } from "../core/environment"; const genKey = (i: number, j: number) => `${i}-${j}`; @@ -132,7 +132,7 @@ const Cell = memo( padding: 0, position: "absolute", top: top, - [isRtlDocument() ? "right" : "left"]: left, + [isRTLDocument() ? "right" : "left"]: left, visibility: vHide || hHide ? "hidden" : "visible", minHeight: height, minWidth: width, diff --git a/src/react/VList.rtl.spec.tsx b/src/react/VList.rtl.spec.tsx index 0587fab94..28ba87547 100644 --- a/src/react/VList.rtl.spec.tsx +++ b/src/react/VList.rtl.spec.tsx @@ -6,7 +6,7 @@ jest.mock("../core/environment", () => { const originalModule = jest.requireActual("../core/environment"); return { ...(originalModule as any), - isRtlDocument: () => true, + isRTLDocument: () => true, }; }); diff --git a/src/react/WVList.rtl.spec.tsx b/src/react/WVList.rtl.spec.tsx index ed412834a..8bced6f10 100644 --- a/src/react/WVList.rtl.spec.tsx +++ b/src/react/WVList.rtl.spec.tsx @@ -6,7 +6,7 @@ jest.mock("../core/environment", () => { const originalModule = jest.requireActual("../core/environment"); return { ...(originalModule as any), - isRtlDocument: () => true, + isRTLDocument: () => true, }; });