Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 538b2ec

Browse files
committed
refactor(preview): use react-version of custom-scrollbar
1 parent b8755d8 commit 538b2ec

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

src/containers/Preview/Viewer.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react'
2+
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react'
23

34
import { TYPE } from '@constant'
45

@@ -85,9 +86,11 @@ const renderViewer = (type, root, attachment, attUser) => {
8586
}
8687

8788
const Viewer = ({ type, root, attachment, attUser }) => (
88-
<Wrapper id="preview-viewer-scroller">
89-
{renderViewer(type, root, attachment, attUser)}
90-
</Wrapper>
89+
<OverlayScrollbarsComponent
90+
options={{ scrollbars: { autoHide: 'scroll', autoHideDelay: 200 } }}
91+
>
92+
<Wrapper>{renderViewer(type, root, attachment, attUser)}</Wrapper>
93+
</OverlayScrollbarsComponent>
9194
)
9295

9396
export default Viewer

src/containers/Preview/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
import React from 'react'
88

99
import { connectStore, buildLog } from '@utils'
10-
import { useShortcut, usePlatform } from '@hooks'
10+
import { useShortcut } from '@hooks'
1111

1212
import SliderPreview from './SliderPreview'
1313
import ModalPreview from './ModalPreview'
1414
import Viewer from './Viewer'
1515

16-
import { useInit, useScrollbar, closePreview } from './logic'
16+
import { useInit, closePreview } from './logic'
1717

1818
/* eslint-disable-next-line */
1919
const log = buildLog('C:Preview')
@@ -22,9 +22,6 @@ const PreviewContainer = ({ preview }) => {
2222
useInit(preview)
2323
useShortcut('esc', closePreview)
2424

25-
const { isMacOS } = usePlatform()
26-
useScrollbar(isMacOS)
27-
2825
const {
2926
modalVisible,
3027
slideVisible,

src/containers/Preview/logic.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ const DataResolver = [
8383
// ###############################
8484
// init & uninit
8585
// ###############################
86-
export const useScrollbar = isMacOS => {
87-
useEffect(() => {
88-
if (isMacOS) {
89-
/* eslint-disable no-undef */
90-
OverlayScrollbars(document.getElementById('preview-viewer-scroller'), {})
91-
}
92-
}, [isMacOS])
93-
}
94-
9586
export const useInit = _store => {
9687
useEffect(() => {
9788
store = _store

src/containers/Preview/styles/viewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from 'styled-components'
33
export const Wrapper = styled.div.attrs(({ id }) => ({
44
id,
55
}))`
6-
height: calc(100% - 10px);
6+
height: 100vh;
77
width: 100%;
88
`
99

0 commit comments

Comments
 (0)