From 420cb1378c06155debbb3d2d2006dc292ec2f452 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Fri, 22 Sep 2023 18:19:40 +0800 Subject: [PATCH] Add scrollbar to HideScrollbar (in development) --- .../css/components/common/hide-scrollbar.scss | 63 ++++++++++++++++--- src/components/common/HideScrollbar.tsx | 23 ++++++- src/pages/MainFramework.tsx | 30 ++++++++- 3 files changed, 104 insertions(+), 12 deletions(-) diff --git a/src/assets/css/components/common/hide-scrollbar.scss b/src/assets/css/components/common/hide-scrollbar.scss index 9d8ffe5..544de0b 100644 --- a/src/assets/css/components/common/hide-scrollbar.scss +++ b/src/assets/css/components/common/hide-scrollbar.scss @@ -1,16 +1,61 @@ +@use '@/assets/css/constants' as constants; + .hide-scrollbar-mask { width: 100%; height: 100%; overflow: hidden; -} -.hide-scrollbar-selection { - position: relative; - overflow: scroll; - scrollbar-width: none; - -ms-overflow-style: none; -} + .hide-scrollbar-selection { + position: relative; + overflow: scroll; + scrollbar-width: none; + -ms-overflow-style: none; + } -.hide-scrollbar-selection::-webkit-scrollbar { - display: none; + ::-webkit-scrollbar { + display: none; + } + + .scrollbar { + position: absolute; + z-index: 1000; + opacity: .5; + + .box { + position: relative; + width: 100%; + height: 100%; + border-radius: 8px; + overflow: hidden; + + + .block { + position: absolute; + width: 100%; + height: 100%; + border-radius: 8px; + background-color: constants.$font-secondary-color; + transition: all .2s; + } + :hover { + background-color: constants.$font-main-color; + } + } + } + + .vertical-scrollbar { + padding: 12px 4px; + width: 16px; + height: 100%; + right: 0; + top: 0; + } + + .horizontal-scrollbar { + padding: 4px 12px; + width: 100%; + height: 16px; + left: 0; + bottom: 0; + } } \ No newline at end of file diff --git a/src/components/common/HideScrollbar.tsx b/src/components/common/HideScrollbar.tsx index 1fcdaa7..9afbc9d 100644 --- a/src/components/common/HideScrollbar.tsx +++ b/src/components/common/HideScrollbar.tsx @@ -47,6 +47,8 @@ const HideScrollbar = forwardRef((prop const lastTouchPosition = useRef<{ x: number; y: number }>({ x: -1, y: -1 }) const [verticalScrollbarWidth, setVerticalScrollbarWidth] = useState(0) const [horizontalScrollbarWidth, setHorizontalScrollbarWidth] = useState(0) + const [verticalScrollbarLength, setVerticalScrollbarLength] = useState(100) + const [horizontalScrollbarLength, setHorizontalScrollbarLength] = useState(100) const { isPreventScroll, @@ -308,12 +310,31 @@ const HideScrollbar = forwardRef((prop tabIndex={0} style={{ width: `calc(100vw + ${verticalScrollbarWidth}px)`, - height: `calc(100vh + ${horizontalScrollbarWidth}px` + height: `calc(100vh + ${horizontalScrollbarWidth}px)` }} {..._props} > {props.children} +