Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
t-skgm committed Jan 9, 2020
1 parent fc55491 commit 9dca34d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/renderer/components/organisms/Launcher/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import * as React from 'react'
import Mousetrap from 'mousetrap'
// import constants from 'constants/index'
// const { key } = constants
import { Direction } from '@/types'

interface Props {
length: number
Expand All @@ -28,22 +27,22 @@ export const useRingPosition = ({ length }: Props) => {
)

const [pos, setPos] = React.useState(0)
const [direction, setDirection] = React.useState<'right' | 'left'>('right')
const [direction, setDirection] = React.useState<Direction>('right')

React.useEffect(() => {
Mousetrap.bind('right', ev => {
console.log('right!')
Mousetrap.bind('right', () => {
console.log('right pressed!')
setPos(rotate(1))
setDirection('right')
})
Mousetrap.bind('left', ev => {
console.log('left!')
Mousetrap.bind('left', () => {
console.log('left pressed!')
setPos(rotate(-1))
setDirection('left')
})

return () => {
// remove all listeners
Mousetrap.reset()
Mousetrap.reset() // remove all listeners
}
}, [rotate])

Expand Down

0 comments on commit 9dca34d

Please sign in to comment.