git ssb

2+

mixmix / ticktack



Tree: 4e6ec20947fcc765efbf7a8e5947553f574943da

Files: 4e6ec20947fcc765efbf7a8e5947553f574943da / app / html / scroller.js

1255 bytesRaw
1const nest = require('depnest')
2const pull = require('pull-stream')
3const Scroller = require('mutant-scroll')
4const next = require('pull-next-step')
5
6exports.gives = nest('app.html.scroller')
7
8exports.needs = nest({
9 'message.html.render': 'first'
10})
11
12exports.create = function (api) {
13 return nest('app.html.scroller', createScroller)
14
15 function createScroller (opts = {}) {
16 const {
17 stream,
18 filter = () => pull.filter((msg) => true),
19 indexProperty = ['value', 'timestamp']
20 } = opts
21
22 const streamToTop = pull(
23 next(stream, {old: false, limit: 100, property: indexProperty }),
24 filter() // is a pull-stream through
25 )
26
27 const streamToBottom = pull(
28 next(stream, {reverse: true, limit: 100, live: false, property: indexProperty }),
29 filter()
30 )
31
32 return Scroller(Object.assign({}, opts, { streamToTop, streamToBottom }))
33 // valid Scroller opts : see github.com/mixmix/mutant-scroll
34 // classList = [],
35 // prepend = [],
36 // append = [],
37 // streamToTop,
38 // streamToBottom,
39 // render,
40 // updateTop = updateTopDefault,
41 // updateBottom = updateBottomDefault,
42 // store = MutantArray(),
43 // cb = (err) => { if (err) throw err }
44 }
45}
46

Built with git-ssb-web