git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 0e85184b798e0dcaa10ed88344b6d6d6527e074c

Files: 0e85184b798e0dcaa10ed88344b6d6d6527e074c / lib / anchor-hook.js

373 bytesRaw
1var watch = require('mutant/watch')
2
3module.exports = AnchorHook
4
5function AnchorHook (name, current, cb) {
6 return function (element) {
7 return watch(current, (current) => {
8 if (current === name) {
9 window.requestAnimationFrame(() => {
10 element.scrollIntoView()
11 if (typeof cb === 'function') cb(element)
12 })
13 }
14 })
15 }
16}
17

Built with git-ssb-web