git ssb

2+

mixmix / ticktack



Tree: e6df29b999257c928b0fe5316875680a479dba2e

Files: e6df29b999257c928b0fe5316875680a479dba2e / app / html / scroller.js

1483 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, // TODO - rename this to createStream (rename across app)
18 filter = () => pull.filter((msg) => true),
19 indexProperty = ['timestamp']
20 } = opts
21
22 const streamToTop = pull(
23 next(stream, { live: true, reverse: false, old: false, limit: 100, property: indexProperty }),
24 filter() // is a pull-stream through
25 )
26
27 const streamToBottom = pull(
28 next(stream, { live: false, reverse: true, limit: 100, property: indexProperty }),
29 filter()
30 )
31
32 const _opts = Object.assign(
33 { overflowY: 'auto' }, // TODO check across app what makes better default
34 opts,
35 { streamToTop, streamToBottom }
36 )
37
38 return Scroller(_opts)
39 // valid Scroller opts : see github.com/mixmix/mutant-scroll
40 // classList = [],
41 // prepend = [],
42 // append = [],
43 // streamToTop,
44 // streamToBottom,
45 // render,
46 // updateTop = updateTopDefault,
47 // updateBottom = updateBottomDefault,
48 // store = MutantArray(),
49 // cb = (err) => { if (err) throw err }
50 // overflowY = 'scroll'
51 }
52}
53

Built with git-ssb-web