git ssb

2+

mixmix / ticktack



Commit bc3baa90f43110f56698bc1c3de13714835c9d08

implement scroller with mutant-scroll

mix irving committed on 11/19/2017, 4:59:55 AM
Parent: f30be9436ba56489c01de7d4c5dfef6669137201

Files changed

app/html/context.jschanged
app/html/scroller.jschanged
package-lock.jsonchanged
package.jsonchanged
app/html/context.jsView
@@ -88,21 +88,21 @@
8888 location: { page: 'blogIndex' },
8989 })
9090 ]
9191
92- const { scroller } = api.app.html.scroller({
92+ return api.app.html.scroller({
9393 classList: [ 'level', '-one' ],
9494 prepend,
95- streamBottom: api.feed.pull.private,
95+ stream: api.feed.pull.private,
9696 filter: pull(
9797 pull.filter(msg => msg.value.content.type === 'post'), // TODO is this the best way to protect against votes?
9898 pull.filter(msg => msg.value.author != myKey),
9999 pull.filter(msg => msg.value.content.recps),
100100 pull.through(updateRecentMsgLog),
101101 pull.filter(isLatestMsg)
102- //pull.through( // trim exisiting from content up Top case)
102+ //pull.through( // trim exisiting from content up Top case) // do this with new updateTop in mutant-scroll
103103 ),
104- renderer: (msg) => {
104+ render: (msg) => {
105105 const { author } = msg.value
106106 if (nearby.has(author)) return
107107
108108 return Option({
@@ -113,10 +113,8 @@
113113 location: Object.assign({}, msg, { feed: author }) // TODO make obs?
114114 })
115115 }
116116 })
117-
118- return scroller
119117 }
120118
121119 function LevelTwoContext () {
122120 const { key, value, feed: targetUser, page } = location
app/html/scroller.jsView
@@ -1,8 +1,8 @@
11 const nest = require('depnest')
22 const { h } = require('mutant')
33 const pull = require('pull-stream')
4-const pullScroll = require('pull-scroll')
4+const Scroller = require('mutant-scroll')
55 const next = require('pull-next-step')
66
77 exports.gives = nest('app.html.scroller')
88
@@ -14,65 +14,74 @@
1414 return nest('app.html.scroller', createScroller)
1515
1616 function createScroller (opts = {}) {
1717 const {
18- streamTop,
19- streamBottom,
20- filter = (msg) => true,
21- renderer,
22- classList = [],
23- content = h('section.content'),
24- prepend = [],
25- append = []
18+ stream,
19+ filter = pull.filter((msg) => true),
20+ // renderer,
21+ // classList = [],
22+ // content = h('section.content'),
23+ // prepend = [],
24+ // append = []
2625 } = opts
2726
28- if (!streamTop && !streamBottom) throw new Error('Scroller requires a at least one stream: streamTop || streamBottom')
29- if (!renderer) throw new Error('Scroller expects a renderer')
27+ const streamToTop = undefined
28+ // pull(
29+ // next(stream, {old: false, limit: 100}, ['value', 'timestamp']),
30+ // filter // is a pull-stream through
31+ // )
3032
31- const scroller = h('Scroller', { classList, style: { overflow: 'auto' } }, [
32- h('div.wrapper', [
33- h('header', prepend),
34- content,
35- h('footer', append)
36- ])
37- ])
38- // scroller.scroll = keyscroll(content) // used for e.g. reset
33+ const streamToBottom = pull(
34+ next(stream, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
35+ filter
36+ )
3937
40- draw()
38+ return Scroller(Object.assign({}, opts, { streamToTop, streamToBottom }))
4139
42- return {
43- scroller,
44- content,
45- // reset,
46- }
40+ // const scroller = h('Scroller', { classList, style: { overflow: 'auto' } }, [
41+ // h('div.wrapper', [
42+ // h('header', prepend),
43+ // content,
44+ // h('footer', append)
45+ // ])
46+ // ])
47+ // // scroller.scroll = keyscroll(content) // used for e.g. reset
4748
48- function draw () {
49- reset()
49+ // draw()
50+
51+ // return {
52+ // scroller,
53+ // content,
54+ // // reset,
55+ // }
56+
57+ // function draw () {
58+ // reset()
5059
51- if (streamTop) {
52- pull(
53- next(streamTop, {old: false, limit: 100}, ['value', 'timestamp']),
54- filter,
55- // filterDownThrough(),
56- pullScroll(scroller, content, renderer, true, false)
57- )
58- }
60+ // if (streamTop) {
61+ // pull(
62+ // next(streamTop, {old: false, limit: 100}, ['value', 'timestamp']),
63+ // filter,
64+ // // filterDownThrough(),
65+ // pullScroll(scroller, content, renderer, true, false)
66+ // )
67+ // }
5968
60- if (streamBottom) {
61- pull(
62- next(streamBottom, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
63- filter,
64- // filterUpThrough(),
65- pullScroll(scroller, content, renderer, false, false)
66- )
67- }
68- }
69+ // if (streamBottom) {
70+ // pull(
71+ // next(streamBottom, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
72+ // filter,
73+ // // filterUpThrough(),
74+ // pullScroll(scroller, content, renderer, false, false)
75+ // )
76+ // }
77+ // }
6978
70- function reset () {
71- }
72-
79+ // function reset () {
80+ // }
81+ // }
82+
7383 }
74-
7584 }
7685
7786 function keyscroll (content) {
7887 var curMsgEl
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 202220 bytes
New file size: 203359 bytes
package.jsonView
@@ -33,8 +33,9 @@
3333 "markdown-summary": "^1.0.3",
3434 "micro-css": "^2.0.1",
3535 "morphdom": "^2.3.3",
3636 "mutant": "^3.21.2",
37+ "mutant-scroll": "0.0.1",
3738 "obv-debounce": "^1.0.2",
3839 "open-external": "^0.1.1",
3940 "patch-profile": "^1.0.2",
4041 "patch-settings": "^1.0.0",

Built with git-ssb-web