This repository was archived by the owner on Nov 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 77import React from 'react'
88
99import { connectStore , buildLog } from '@utils'
10- import { useShortcut } from '@hooks'
10+ import { useShortcut , usePlatform } from '@hooks'
1111
1212import SliderPreview from './SliderPreview'
1313import ModalPreview from './ModalPreview'
1414import Viewer from './Viewer'
1515
16- import { useInit , closePreview } from './logic'
16+ import { useInit , useScrollbar , closePreview } from './logic'
1717
1818/* eslint-disable-next-line */
1919const log = buildLog ( 'C:Preview' )
@@ -22,6 +22,9 @@ const PreviewContainer = ({ preview }) => {
2222 useInit ( preview )
2323 useShortcut ( 'esc' , closePreview )
2424
25+ const { isMacOS } = usePlatform ( )
26+ useScrollbar ( isMacOS )
27+
2528 const {
2629 modalVisible,
2730 slideVisible,
Original file line number Diff line number Diff line change @@ -83,15 +83,20 @@ 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+
8695export const useInit = _store => {
8796 useEffect ( ( ) => {
8897 store = _store
89-
9098 sub$ = sr71$ . data ( ) . subscribe ( $solver ( DataResolver , [ ] ) )
9199
92- /* eslint-disable no-undef */
93- OverlayScrollbars ( document . getElementById ( 'preview-viewer-scroller' ) , { } )
94-
95100 return ( ) => {
96101 if ( ! sub$ ) return false
97102 sr71$ . stop ( )
You can’t perform that action at this time.
0 commit comments