git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 3ce9f274492ef4b74c0de22ed8b53fa746fe0c4d

Files: 3ce9f274492ef4b74c0de22ed8b53fa746fe0c4d / lib / observe-link-hover.js

609 bytesRaw
1var Sustained = require('./sustained')
2var Value = require('mutant/value')
3
4module.exports = function (root, delay) {
5 var target = Value()
6 root.addEventListener('mouseover', (ev) => {
7 var anchor = null
8 for (var n = ev.target; n.parentNode; n = n.parentNode) {
9 if (n.nodeName === 'A') {
10 anchor = n
11 break
12 }
13 }
14 target.set(anchor)
15 })
16
17 root.addEventListener('mouseleave', (ev) => {
18 target.set(false)
19 })
20
21 var result = Sustained(target, delay || 500, (v) => {
22 return v === undefined
23 })
24
25 result.cancel = () => target.set(undefined)
26 return result
27}
28

Built with git-ssb-web