mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-18 12:30:35 +03:00
improve code
This commit is contained in:
+13
-10
@@ -54,6 +54,7 @@ export type HideNativeScrollbars = (
|
|||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
const { max } = Math;
|
const { max } = Math;
|
||||||
|
const max0 = max.bind(0, 0);
|
||||||
const strVisible = 'visible';
|
const strVisible = 'visible';
|
||||||
const strHidden = 'hidden';
|
const strHidden = 'hidden';
|
||||||
const overlaidScrollbarsHideOffset = 42;
|
const overlaidScrollbarsHideOffset = 42;
|
||||||
@@ -69,8 +70,8 @@ const xyCacheOptions = {
|
|||||||
const getOverflowAmount = (viewportScrollSize: WH<number>, viewportClientSize: WH<number>) => {
|
const getOverflowAmount = (viewportScrollSize: WH<number>, viewportClientSize: WH<number>) => {
|
||||||
const tollerance = window.devicePixelRatio % 1 !== 0 ? 1 : 0;
|
const tollerance = window.devicePixelRatio % 1 !== 0 ? 1 : 0;
|
||||||
const amount = {
|
const amount = {
|
||||||
w: max(0, viewportScrollSize.w - viewportClientSize.w),
|
w: max0(viewportScrollSize.w - viewportClientSize.w),
|
||||||
h: max(0, viewportScrollSize.h - viewportClientSize.h),
|
h: max0(viewportScrollSize.h - viewportClientSize.h),
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -407,18 +408,20 @@ export const createOverflowUpdate: CreateStructureUpdateSegment = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const overflowAmountScrollSize = {
|
const overflowAmountScrollSize = {
|
||||||
w: max(viewportScrollSize.w, arrangedViewportScrollSize.w) + sizeFraction.w,
|
w: max0(max(viewportScrollSize.w, arrangedViewportScrollSize.w) + sizeFraction.w),
|
||||||
h: max(viewportScrollSize.h, arrangedViewportScrollSize.h) + sizeFraction.h,
|
h: max0(max(viewportScrollSize.h, arrangedViewportScrollSize.h) + sizeFraction.h),
|
||||||
};
|
};
|
||||||
const overflowAmountClientSize = {
|
const overflowAmountClientSize = {
|
||||||
w:
|
w: max0(
|
||||||
arrangedViewportClientSize.w +
|
arrangedViewportClientSize.w +
|
||||||
max(0, viewportclientSize.w - viewportScrollSize.w) +
|
max0(viewportclientSize.w - viewportScrollSize.w) +
|
||||||
sizeFraction.w,
|
sizeFraction.w
|
||||||
h:
|
),
|
||||||
|
h: max0(
|
||||||
arrangedViewportClientSize.h +
|
arrangedViewportClientSize.h +
|
||||||
max(0, viewportclientSize.h - viewportScrollSize.h) +
|
max0(viewportclientSize.h - viewportScrollSize.h) +
|
||||||
sizeFraction.h,
|
sizeFraction.h
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
overflowEdgeCache = updateOverflowEdge(overflowAmountClientSize);
|
overflowEdgeCache = updateOverflowEdge(overflowAmountClientSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user