Renamed hoverable -> focusable
This commit is contained in:
29
src/actions/focusable/focusable.js
Normal file
29
src/actions/focusable/focusable.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createDispatcher } from '../../utils/event'
|
||||
import {
|
||||
addFocusinEventListener,
|
||||
removeFocusinEventListener,
|
||||
addFocusoutEventListener,
|
||||
removeFocusoutEventListener,
|
||||
} from './event'
|
||||
|
||||
export function focusable(node) {
|
||||
const dispatch = createDispatcher(node)
|
||||
|
||||
function handleFocusin() {
|
||||
dispatch('focused', { value: true })
|
||||
}
|
||||
|
||||
function handleFocusout() {
|
||||
dispatch('focused', { value: false })
|
||||
}
|
||||
|
||||
addFocusinEventListener(node, handleFocusin)
|
||||
addFocusoutEventListener(node, handleFocusout)
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
removeFocusinEventListener(node, handleFocusin)
|
||||
removeFocusoutEventListener(node, handleFocusout)
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user