Commit c9b2708a2c9961e39c5c2370d526d929215013df
Factor keyscroll usage out of feeds into tabs
Charles Lehner committed on 6/27/2016, 6:37:03 PMParent: 437facf41d277081453b193b5e9cc808704399ef
Files changed
keyscroll.js | changed |
modules/feed.js | changed |
modules/private.js | changed |
modules/public.js | changed |
modules/tabs.js | changed |
modules/thread.js | changed |
keyscroll.js | ||
---|---|---|
@@ -1,7 +1,10 @@ | ||
1 | 1 | module.exports = function (container) { |
2 | 2 | var curMsgEl |
3 | 3 | |
4 | + if (!container) | |
5 | + return function() {} | |
6 | + | |
4 | 7 | container.addEventListener('click', onActivateChild, false) |
5 | 8 | container.addEventListener('focus', onActivateChild, true) |
6 | 9 | |
7 | 10 | function onActivateChild(ev) { |
modules/feed.js | ||
---|---|---|
@@ -3,9 +3,8 @@ | ||
3 | 3 | var Scroller = require('pull-scroll') |
4 | 4 | var h = require('hyperscript') |
5 | 5 | var pull = require('pull-stream') |
6 | 6 | var u = require('../util') |
7 | -var keyscroll = require('../keyscroll') | |
8 | 7 | |
9 | 8 | var plugs = require('../plugs') |
10 | 9 | var sbot_user_feed = plugs.first(exports.sbot_user_feed = []) |
11 | 10 | var message_render = plugs.first(exports.message_render = []) |
@@ -39,10 +38,8 @@ | ||
39 | 38 | }, ['value', 'sequence']), |
40 | 39 | Scroller(div, content, message_render, false, false) |
41 | 40 | ) |
42 | 41 | |
43 | - div.scroll = keyscroll(content) | |
44 | - | |
45 | 42 | return div |
46 | 43 | |
47 | 44 | } |
48 | 45 | } |
modules/private.js | ||
---|---|---|
@@ -2,9 +2,8 @@ | ||
2 | 2 | var ui = require('../ui') |
3 | 3 | var u = require('../util') |
4 | 4 | var pull = require('pull-stream') |
5 | 5 | var Scroller = require('pull-scroll') |
6 | -var keyscroll = require('../keyscroll') | |
7 | 6 | var ref = require('ssb-ref') |
8 | 7 | |
9 | 8 | var plugs = require('../plugs') |
10 | 9 | |
@@ -63,10 +62,8 @@ | ||
63 | 62 | if(err) throw err |
64 | 63 | }) |
65 | 64 | ) |
66 | 65 | |
67 | - div.scroll = keyscroll(content) | |
68 | - | |
69 | 66 | return div |
70 | 67 | } |
71 | 68 | } |
72 | 69 |
modules/public.js | ||
---|---|---|
@@ -2,9 +2,8 @@ | ||
2 | 2 | var ui = require('../ui') |
3 | 3 | var u = require('../util') |
4 | 4 | var pull = require('pull-stream') |
5 | 5 | var Scroller = require('pull-scroll') |
6 | -var keyscroll = require('../keyscroll') | |
7 | 6 | |
8 | 7 | var plugs = require('../plugs') |
9 | 8 | var message_render = plugs.first(exports.message_render = []) |
10 | 9 | var message_compose = plugs.first(exports.message_compose = []) |
@@ -31,10 +30,8 @@ | ||
31 | 30 | u.next(sbot_log, {reverse: true, limit: 100, live: false}), |
32 | 31 | Scroller(div, content, message_render, false, false) |
33 | 32 | ) |
34 | 33 | |
35 | - div.scroll = keyscroll(content) | |
36 | - | |
37 | 34 | return div |
38 | 35 | } |
39 | 36 | } |
40 | 37 |
modules/tabs.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | 1 | var Tabs = require('hypertabs') |
2 | 2 | var h = require('hyperscript') |
3 | 3 | var pull = require('pull-stream') |
4 | 4 | var u = require('../util') |
5 | +var keyscroll = require('../keyscroll') | |
5 | 6 | |
6 | 7 | function ancestor (el) { |
7 | 8 | if(!el) return |
8 | 9 | if(el.tagName !== 'A') return ancestor(el.parentElement) |
@@ -38,8 +39,9 @@ | ||
38 | 39 | catch (_) { saved = ['/public', '/private'] } |
39 | 40 | |
40 | 41 | saved.forEach(function (path) { |
41 | 42 | var el = screen_view(path) |
43 | + el.scroll = keyscroll(el.querySelector('.scroller__content')) | |
42 | 44 | if(el) tabs.add(path, el, true) |
43 | 45 | }) |
44 | 46 | |
45 | 47 | tabs.select(saved[0] || '/public') |
@@ -59,8 +61,9 @@ | ||
59 | 61 | if(tabs.has(path)) return tabs.select(path) |
60 | 62 | |
61 | 63 | var el = screen_view(path) |
62 | 64 | if(el) { |
65 | + el.scroll = keyscroll(el.querySelector('.scroller__content')) | |
63 | 66 | tabs.add(path, el, !ev.ctrlKey) |
64 | 67 | localStorage.openTabs = JSON.stringify(tabs.tabs) |
65 | 68 | } |
66 | 69 | } |
modules/thread.js | ||
---|---|---|
@@ -5,9 +5,8 @@ | ||
5 | 5 | var ref = require('ssb-ref') |
6 | 6 | var h = require('hyperscript') |
7 | 7 | var u = require('../util') |
8 | 8 | var Scroller = require('pull-scroll') |
9 | -var keyscroll = require('../keyscroll') | |
10 | 9 | |
11 | 10 | function once (cont) { |
12 | 11 | var ended = false |
13 | 12 | return function (abort, cb) { |
@@ -104,9 +103,8 @@ | ||
104 | 103 | }) |
105 | 104 | } |
106 | 105 | |
107 | 106 | loadThread() |
108 | - div.scroll = keyscroll(content) | |
109 | 107 | return div |
110 | 108 | } |
111 | 109 | } |
112 | 110 |
Built with git-ssb-web