2018-02-09 07:29:29 +01:00
|
|
|
export function mouseover (node, callback) {
|
|
|
|
function onMouseEnter () {
|
|
|
|
callback(true) // eslint-disable-line
|
2018-02-01 03:20:30 +01:00
|
|
|
}
|
2018-02-09 07:29:29 +01:00
|
|
|
function onMouseLeave () {
|
|
|
|
callback(false) // eslint-disable-line
|
2018-02-01 03:20:30 +01:00
|
|
|
}
|
|
|
|
node.addEventListener('mouseenter', onMouseEnter)
|
|
|
|
node.addEventListener('mouseleave', onMouseLeave)
|
|
|
|
return {
|
2018-04-30 07:13:41 +02:00
|
|
|
destroy () {
|
2018-02-01 03:20:30 +01:00
|
|
|
node.removeEventListener('mouseenter', onMouseEnter)
|
|
|
|
node.removeEventListener('mouseleave', onMouseLeave)
|
|
|
|
}
|
|
|
|
}
|
2018-02-09 07:29:29 +01:00
|
|
|
}
|
2018-02-10 22:57:04 +01:00
|
|
|
|
|
|
|
export function focusWithCapture (node, callback) {
|
|
|
|
node.addEventListener('focus', callback, true)
|
|
|
|
return {
|
2018-04-30 07:13:41 +02:00
|
|
|
destroy () {
|
2018-02-10 22:57:04 +01:00
|
|
|
node.removeEventListener('focus', callback, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function blurWithCapture (node, callback) {
|
|
|
|
node.addEventListener('blur', callback, true)
|
|
|
|
return {
|
2018-04-30 07:13:41 +02:00
|
|
|
destroy () {
|
2018-02-10 22:57:04 +01:00
|
|
|
node.removeEventListener('blur', callback, true)
|
|
|
|
}
|
|
|
|
}
|
2018-02-11 18:37:13 +01:00
|
|
|
}
|
2018-03-25 03:04:54 +02:00
|
|
|
|
|
|
|
export function selectionChange (node, callback) {
|
|
|
|
let events = ['keyup', 'click', 'focus', 'blur']
|
|
|
|
let listener = () => {
|
|
|
|
callback(node.selectionStart)
|
|
|
|
}
|
|
|
|
for (let event of events) {
|
|
|
|
node.addEventListener(event, listener)
|
|
|
|
}
|
|
|
|
return {
|
2018-04-30 07:13:41 +02:00
|
|
|
destroy () {
|
2018-03-25 03:04:54 +02:00
|
|
|
for (let event of events) {
|
|
|
|
node.removeEventListener(event, listener)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|