Add click switch to Indicator. Add scrollbar to HideScrollbar. Fix scroll down when horizontal scroll bug. Refactor the HideScrollbar. #22
@@ -1,16 +1,61 @@
|
|||||||
|
@use '@/assets/css/constants' as constants;
|
||||||
|
|
||||||
.hide-scrollbar-mask {
|
.hide-scrollbar-mask {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
|
||||||
|
|
||||||
.hide-scrollbar-selection {
|
.hide-scrollbar-selection {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
-ms-overflow-style: none;
|
-ms-overflow-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hide-scrollbar-selection::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
display: none;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -47,6 +47,8 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>((prop
|
|||||||
const lastTouchPosition = useRef<{ x: number; y: number }>({ x: -1, y: -1 })
|
const lastTouchPosition = useRef<{ x: number; y: number }>({ x: -1, y: -1 })
|
||||||
const [verticalScrollbarWidth, setVerticalScrollbarWidth] = useState(0)
|
const [verticalScrollbarWidth, setVerticalScrollbarWidth] = useState(0)
|
||||||
const [horizontalScrollbarWidth, setHorizontalScrollbarWidth] = useState(0)
|
const [horizontalScrollbarWidth, setHorizontalScrollbarWidth] = useState(0)
|
||||||
|
const [verticalScrollbarLength, setVerticalScrollbarLength] = useState(100)
|
||||||
|
const [horizontalScrollbarLength, setHorizontalScrollbarLength] = useState(100)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isPreventScroll,
|
isPreventScroll,
|
||||||
@@ -308,12 +310,31 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>((prop
|
|||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
style={{
|
style={{
|
||||||
width: `calc(100vw + ${verticalScrollbarWidth}px)`,
|
width: `calc(100vw + ${verticalScrollbarWidth}px)`,
|
||||||
height: `calc(100vh + ${horizontalScrollbarWidth}px`
|
height: `calc(100vh + ${horizontalScrollbarWidth}px)`
|
||||||
}}
|
}}
|
||||||
{..._props}
|
{..._props}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</div>
|
||||||
|
<div hidden={!isShowVerticalScrollbar} className={'scrollbar vertical-scrollbar'}>
|
||||||
|
<div className={'box'}>
|
||||||
|
<div
|
||||||
|
className={'block'}
|
||||||
|
style={{ height: `${verticalScrollbarLength}%` }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
hidden={!isShowHorizontalScrollbar}
|
||||||
|
className={'scrollbar horizontal-scrollbar'}
|
||||||
|
>
|
||||||
|
<div className={'box'}>
|
||||||
|
<div
|
||||||
|
className={'block'}
|
||||||
|
style={{ width: `${horizontalScrollbarLength}%` }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,17 +13,33 @@ export const MainFrameworkContext = createContext<{
|
|||||||
preventScroll: boolean
|
preventScroll: boolean
|
||||||
setPreventScroll: (newValue: boolean) => void
|
setPreventScroll: (newValue: boolean) => void
|
||||||
}
|
}
|
||||||
|
showVerticalScrollbarState: {
|
||||||
|
showVerticalScrollbar: boolean
|
||||||
|
setShowVerticalScrollbar: (newValue: boolean) => void
|
||||||
|
}
|
||||||
|
showHorizontalScrollbarState: {
|
||||||
|
showHorizontalScrollbar: boolean
|
||||||
|
setShowHorizontalScrollbar: (newValue: boolean) => void
|
||||||
|
}
|
||||||
hideScrollbarRef: React.RefObject<HideScrollbarElement>
|
hideScrollbarRef: React.RefObject<HideScrollbarElement>
|
||||||
}>({
|
}>({
|
||||||
navbarHiddenState: {
|
navbarHiddenState: {
|
||||||
navbarHidden: false,
|
navbarHidden: false,
|
||||||
setNavbarHidden: () => undefined
|
setNavbarHidden: () => undefined
|
||||||
},
|
},
|
||||||
hideScrollbarRef: createRef(),
|
|
||||||
preventScrollState: {
|
preventScrollState: {
|
||||||
preventScroll: false,
|
preventScroll: false,
|
||||||
setPreventScroll: () => undefined
|
setPreventScroll: () => undefined
|
||||||
}
|
},
|
||||||
|
showVerticalScrollbarState: {
|
||||||
|
showVerticalScrollbar: false,
|
||||||
|
setShowVerticalScrollbar: () => undefined
|
||||||
|
},
|
||||||
|
showHorizontalScrollbarState: {
|
||||||
|
showHorizontalScrollbar: false,
|
||||||
|
setShowHorizontalScrollbar: () => undefined
|
||||||
|
},
|
||||||
|
hideScrollbarRef: createRef()
|
||||||
})
|
})
|
||||||
|
|
||||||
const MainFramework: React.FC = () => {
|
const MainFramework: React.FC = () => {
|
||||||
@@ -36,6 +52,8 @@ const MainFramework: React.FC = () => {
|
|||||||
|
|
||||||
const [navbarHidden, setNavbarHidden] = useState(true)
|
const [navbarHidden, setNavbarHidden] = useState(true)
|
||||||
const [preventScroll, setPreventScroll] = useState(false)
|
const [preventScroll, setPreventScroll] = useState(false)
|
||||||
|
const [showVerticalScrollbar, setShowVerticalScrollbar] = useState(false)
|
||||||
|
const [showHorizontalScrollbar, setShowHorizontalScrollbar] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setNavbarHidden(false)
|
setNavbarHidden(false)
|
||||||
@@ -73,6 +91,14 @@ const MainFramework: React.FC = () => {
|
|||||||
value={{
|
value={{
|
||||||
navbarHiddenState: { navbarHidden, setNavbarHidden },
|
navbarHiddenState: { navbarHidden, setNavbarHidden },
|
||||||
preventScrollState: { preventScroll, setPreventScroll },
|
preventScrollState: { preventScroll, setPreventScroll },
|
||||||
|
showVerticalScrollbarState: {
|
||||||
|
showVerticalScrollbar,
|
||||||
|
setShowVerticalScrollbar
|
||||||
|
},
|
||||||
|
showHorizontalScrollbarState: {
|
||||||
|
showHorizontalScrollbar,
|
||||||
|
setShowHorizontalScrollbar
|
||||||
|
},
|
||||||
hideScrollbarRef
|
hideScrollbarRef
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user