#49 : Separate handlers for touchable and non toachable devices
This commit is contained in:
27
src/actions/pausable/pausable.js
Normal file
27
src/actions/pausable/pausable.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { createDispatcher, getIsTouchable } from '../../utils/event'
|
||||
|
||||
import { focusable } from '../focusable'
|
||||
import { tappable } from '../tappable'
|
||||
|
||||
export function pausable(node) {
|
||||
const dispatch = createDispatcher(node)
|
||||
|
||||
if (getIsTouchable()) {
|
||||
return tappable(node, {
|
||||
dispatch: (_, payload) => {
|
||||
dispatch('pausedToggle', {
|
||||
isTouchable: true,
|
||||
...payload
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
return focusable(node, {
|
||||
dispatch: (_, payload) => {
|
||||
dispatch('pausedToggle', {
|
||||
isTouchable: false,
|
||||
...payload
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user