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

Commit 83add4b

Browse files
committed
refactor(scrollbar): init scrollbar on doramon only for mac
1 parent 6a65cf0 commit 83add4b

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

containers/Doraemon/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import React from 'react'
88

99
import { connectStore, buildLog } from '@utils'
10+
import { usePlatform } from '@hooks'
11+
1012
import { PageOverlay, PanelContainer } from './styles'
1113

1214
import InputEditor from './InputEditor'
@@ -16,13 +18,15 @@ import ThreadSelectBar from './ThreadSelectBar'
1618
import AlertBar from './AlertBar'
1719
import UtilsBar from './UtilsBar'
1820

19-
import * as logic from './logic'
21+
import { useInit, useScrollbar, hidePanel } from './logic'
2022

2123
/* eslint-disable-next-line */
2224
const log = buildLog('C:Doraemon')
2325

2426
const DoraemonContainer = ({ doraemon }) => {
25-
logic.useInit(doraemon)
27+
useInit(doraemon)
28+
const { isMacOS } = usePlatform()
29+
useScrollbar(isMacOS)
2630

2731
const {
2832
inputValue,
@@ -43,7 +47,7 @@ const DoraemonContainer = ({ doraemon }) => {
4347

4448
return (
4549
<React.Fragment>
46-
<PageOverlay visible={visible} onClick={logic.hidePanel} />
50+
<PageOverlay visible={visible} onClick={hidePanel} />
4751
<PanelContainer visible={visible}>
4852
<InputEditor value={inputValue} searching={searching} prefix={prefix} />
4953

containers/Doraemon/logic/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,16 +493,22 @@ const initSpecCmdResolver = () => {
493493
// ###############################
494494
// init & uninit handlers
495495
// ###############################
496+
export const useScrollbar = isMacOS => {
497+
useEffect(() => {
498+
if (isMacOS) {
499+
/* eslint-disable no-undef */
500+
OverlayScrollbars(document.getElementById('suggestion-scroller'), {})
501+
}
502+
}, [isMacOS])
503+
}
504+
496505
export const useInit = _store => {
497506
useEffect(() => {
498507
store = _store
499508

500509
pockect$ = new Pocket(store)
501510
SAK = new SwissArmyKnife(store)
502511

503-
/* eslint-disable no-undef */
504-
OverlayScrollbars(document.getElementById('suggestion-scroller'), {})
505-
506512
initSpecCmdResolver()
507513

508514
pockect$.search().subscribe(res => {

0 commit comments

Comments
 (0)