Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed Oct 8, 2023
1 parent 5592c5d commit 257e20b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/core/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
});
16 changes: 8 additions & 8 deletions src/core/scroller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hasNegativeOffsetInRtl, isRtlDocument } from "./environment";
import { hasNegativeOffsetInRTL, isRTLDocument } from "./environment";
import {
ACTION_SCROLL,
ACTION_BEFORE_MANUAL_SCROLL,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
};
Expand Down Expand Up @@ -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;
};
Expand All @@ -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]);

Expand Down
4 changes: 2 additions & 2 deletions src/react/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -68,7 +68,7 @@ export const ListItem = memo(
<Element
ref={ref}
style={useMemo((): CSSProperties => {
const leftOrRightKey = isRtlDocument() ? "right" : "left";
const leftOrRightKey = isRTLDocument() ? "right" : "left";
const style: CSSProperties = {
margin: 0,
padding: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/react/VGrid.rtl.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jest.mock("../core/environment", () => {
const originalModule = jest.requireActual("../core/environment");
return {
...(originalModule as any),
isRtlDocument: () => true,
isRTLDocument: () => true,
};
});

Expand Down
4 changes: 2 additions & 2 deletions src/react/VGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/react/VList.rtl.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jest.mock("../core/environment", () => {
const originalModule = jest.requireActual("../core/environment");
return {
...(originalModule as any),
isRtlDocument: () => true,
isRTLDocument: () => true,
};
});

Expand Down
2 changes: 1 addition & 1 deletion src/react/WVList.rtl.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jest.mock("../core/environment", () => {
const originalModule = jest.requireActual("../core/environment");
return {
...(originalModule as any),
isRtlDocument: () => true,
isRTLDocument: () => true,
};
});

Expand Down

0 comments on commit 257e20b

Please sign in to comment.