Commit dd6a279d35c61c3c1a36d453b6e27af326a3fc67
rename "scroll" to "keyboardScroll" (was colliding with native scroll API)
mixmix committed on 11/23/2018, 4:06:16 AMParent: 6d8b19c2ddca9ab63af6775ccb64d0942a23d808
Files changed
app/html/filter.js | changed |
app/html/scroller.js | changed |
app/page/calendar.js | changed |
app/page/channel.js | changed |
app/page/postRank.js | changed |
app/page/posts.js | changed |
app/page/private.js | changed |
app/sync/catch-keyboard-shortcut.js | changed |
app/html/filter.js | ||
---|---|---|
@@ -236,9 +236,9 @@ | ||
236 | 236 … | } |
237 | 237 … | upScrollAborter = Abort() |
238 | 238 … | downScrollAborter = Abort() |
239 | 239 … | |
240 | - container.scroll(0) | |
240 … | + container.keyboardScroll(0) | |
241 | 241 … | content.innerHTML = '' |
242 | 242 … | } |
243 | 243 … | |
244 | 244 … | return { |
app/html/scroller.js | ||
---|---|---|
@@ -26,18 +26,18 @@ | ||
26 | 26 … | append ? h('section.bottom', append) : null |
27 | 27 … | ] |
28 | 28 … | ) |
29 | 29 … | |
30 | - container.scroll = keyscroll(contentSection, scrollIntoView) | |
30 … | + container.keyboardScroll = KeyboardScroll(contentSection, scrollIntoView) | |
31 | 31 … | |
32 | 32 … | return { |
33 | 33 … | content: contentSection, |
34 | 34 … | container |
35 | 35 … | } |
36 | 36 … | } |
37 | 37 … | } |
38 | 38 … | |
39 | -function keyscroll (content, scrollIntoView = false) { | |
39 … | +function KeyboardScroll (content, scrollIntoView = false) { | |
40 | 40 … | var curMsgEl |
41 | 41 … | |
42 | 42 … | if (!content) return () => {} |
43 | 43 … | |
@@ -58,9 +58,11 @@ | ||
58 | 58 … | : (!curMsgEl || d === 'last') ? content.lastChild |
59 | 59 … | : d < 0 ? curMsgEl.previousElementSibling || content.firstChild |
60 | 60 … | : d > 0 ? curMsgEl.nextElementSibling || content.lastChild |
61 | 61 … | : curMsgEl |
62 … | + | |
62 | 63 … | selectChild(child) |
64 … | + curMsgEl = child | |
63 | 65 … | |
64 | 66 … | return curMsgEl |
65 | 67 … | } |
66 | 68 … | |
@@ -70,11 +72,12 @@ | ||
70 | 72 … | if (scrollIntoView) { |
71 | 73 … | if (!el.scrollIntoViewIfNeeded && !el.scrollIntoView) return |
72 | 74 … | ;(el.scrollIntoViewIfNeeded || el.scrollIntoView).call(el) |
73 | 75 … | } else { |
74 | - content.parentElement.scrollTop = el.offsetTop - content.parentElement.offsetTop - 10 | |
76 … | + const height = el.offsetTop - content.parentElement.offsetTop - 10 | |
77 … | + // content.parentElement.scroll({ top: height, behavior: 'smooth' }) | |
78 … | + content.parentElement.scrollTop = height | |
75 | 79 … | } |
76 | 80 … | |
77 | 81 … | if (el.focus) el.focus() |
78 | - curMsgEl = el | |
79 | 82 … | } |
80 | 83 … | } |
app/page/calendar.js | ||
---|---|---|
@@ -56,9 +56,9 @@ | ||
56 | 56 … | Calendar(state, actions), |
57 | 57 … | Events(state, api) |
58 | 58 … | ]) |
59 | 59 … | |
60 | - page.scroll = (i) => scroll(state.range, i) | |
60 … | + page.keyboardScroll = (i) => scroll(state.range, i) | |
61 | 61 … | |
62 | 62 … | return page |
63 | 63 … | } |
64 | 64 … |
app/page/channel.js | ||
---|---|---|
@@ -69,9 +69,9 @@ | ||
69 | 69 … | container |
70 | 70 … | ]) |
71 | 71 … | |
72 | 72 … | // TODO better scroll hack for keyboard shortcuts |
73 | - page.scroll = container.scroll | |
73 … | + page.keyboardScroll = container.keyboardScroll | |
74 | 74 … | |
75 | 75 … | return page |
76 | 76 … | } |
77 | 77 … | } |
app/page/postRank.js | ||
---|---|---|
@@ -150,9 +150,9 @@ | ||
150 | 150 … | const { container, content } = api.app.html.scroller({ prepend: top }) |
151 | 151 … | |
152 | 152 … | function draw () { |
153 | 153 … | // reset |
154 | - container.scroll(0) | |
154 … | + container.keyboardScroll(0) | |
155 | 155 … | content.innerHTML = '' |
156 | 156 … | |
157 | 157 … | getPosts(channelPostBoost, friendPostBoost, friendVoteBoost, friendCommentBoost, threshold, |
158 | 158 … | (msgs) => { |
app/page/posts.js | ||
---|---|---|
@@ -89,9 +89,9 @@ | ||
89 | 89 … | if (state.sort === BY_START) page = PageByStart(state) |
90 | 90 … | |
91 | 91 … | page.title = '/posts' |
92 | 92 … | page.id = api.app.sync.locationId({ page: 'posts' }) // this is needed because our page is a computed |
93 | - page.scroll = keyscroll(page.querySelector('section.content')) | |
93 … | + page.keyboardScroll = keyscroll(page.querySelector('section.content')) | |
94 | 94 … | return page |
95 | 95 … | }) |
96 | 96 … | |
97 | 97 … | function PageByUpdate (state) { |
app/page/private.js | ||
---|---|---|
@@ -46,24 +46,24 @@ | ||
46 | 46 … | content.recps = [id, ...(content.mentions || [])] |
47 | 47 … | .filter(m => ref.isFeed(typeof m === 'string' ? m : m.link)) |
48 | 48 … | return content |
49 | 49 … | }, |
50 | - placeholder: 'Write a private message. \n\n@mention users in the first message to start a private thread.'} | |
50 … | + placeholder: 'Write a private message. \n\n@mention users in the first message to start a private thread.' } | |
51 | 51 … | ) |
52 | 52 … | const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw) |
53 | 53 … | const { container, content } = api.app.html.scroller({ prepend: [ composer, filterMenu ] }) |
54 | 54 … | |
55 | 55 … | function draw () { |
56 | 56 … | resetFeed({ container, content }) |
57 | 57 … | |
58 | 58 … | pull( |
59 | - pullPrivate({old: false, live: true}), | |
59 … | + pullPrivate({ old: false, live: true }), | |
60 | 60 … | filterDownThrough(), |
61 | 61 … | Scroller(container, content, api.message.html.render, true, false) |
62 | 62 … | ) |
63 | 63 … | |
64 | 64 … | pull( |
65 | - pullPrivate({reverse: true}), | |
65 … | + pullPrivate({ reverse: true }), | |
66 | 66 … | filterUpThrough(), |
67 | 67 … | Scroller(container, content, api.message.html.render, false, false) |
68 | 68 … | ) |
69 | 69 … | } |
@@ -75,12 +75,12 @@ | ||
75 | 75 … | |
76 | 76 … | function pullPrivate (opts) { |
77 | 77 … | const query = [{ |
78 | 78 … | $filter: { |
79 | - timestamp: {$gt: 0}, | |
79 … | + timestamp: { $gt: 0 }, | |
80 | 80 … | value: { |
81 | 81 … | content: { |
82 | - recps: {$truthy: true} | |
82 … | + recps: { $truthy: true } | |
83 | 83 … | } |
84 | 84 … | } |
85 | 85 … | } |
86 | 86 … | }] |
app/sync/catch-keyboard-shortcut.js | ||
---|---|---|
@@ -48,9 +48,9 @@ | ||
48 | 48 … | const currentPage = tabs.currentPage() |
49 | 49 … | // TODO change this scroll API - it seems some pages |
50 | 50 … | // (e.g. Dark Crystal Index) has scroll defined and expect an object |
51 | 51 … | if (currentPage) { |
52 | - scroll = currentPage.scroll | |
52 … | + scroll = currentPage.keyboardScroll || noop | |
53 | 53 … | } else { |
54 | 54 … | scroll = noop |
55 | 55 … | } |
56 | 56 … |
Built with git-ssb-web