git ssb

2+

mixmix / ticktack



Tree: 3d4eca03f309655578710ab4453f309c514268d1

Files: 3d4eca03f309655578710ab4453f309c514268d1 / app / html / scroller.js

1334 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 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