git ssb

16+

Dominic / patchbay



Commit dd6a279d35c61c3c1a36d453b6e27af326a3fc67

rename "scroll" to "keyboardScroll" (was colliding with native scroll API)

mixmix committed on 11/23/2018, 4:06:16 AM
Parent: 6d8b19c2ddca9ab63af6775ccb64d0942a23d808

Files changed

app/html/filter.jschanged
app/html/scroller.jschanged
app/page/calendar.jschanged
app/page/channel.jschanged
app/page/postRank.jschanged
app/page/posts.jschanged
app/page/private.jschanged
app/sync/catch-keyboard-shortcut.jschanged
app/html/filter.jsView
@@ -236,9 +236,9 @@
236236 }
237237 upScrollAborter = Abort()
238238 downScrollAborter = Abort()
239239
240- container.scroll(0)
240 + container.keyboardScroll(0)
241241 content.innerHTML = ''
242242 }
243243
244244 return {
app/html/scroller.jsView
@@ -26,18 +26,18 @@
2626 append ? h('section.bottom', append) : null
2727 ]
2828 )
2929
30- container.scroll = keyscroll(contentSection, scrollIntoView)
30 + container.keyboardScroll = KeyboardScroll(contentSection, scrollIntoView)
3131
3232 return {
3333 content: contentSection,
3434 container
3535 }
3636 }
3737 }
3838
39-function keyscroll (content, scrollIntoView = false) {
39 +function KeyboardScroll (content, scrollIntoView = false) {
4040 var curMsgEl
4141
4242 if (!content) return () => {}
4343
@@ -58,9 +58,11 @@
5858 : (!curMsgEl || d === 'last') ? content.lastChild
5959 : d < 0 ? curMsgEl.previousElementSibling || content.firstChild
6060 : d > 0 ? curMsgEl.nextElementSibling || content.lastChild
6161 : curMsgEl
62 +
6263 selectChild(child)
64 + curMsgEl = child
6365
6466 return curMsgEl
6567 }
6668
@@ -70,11 +72,12 @@
7072 if (scrollIntoView) {
7173 if (!el.scrollIntoViewIfNeeded && !el.scrollIntoView) return
7274 ;(el.scrollIntoViewIfNeeded || el.scrollIntoView).call(el)
7375 } 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
7579 }
7680
7781 if (el.focus) el.focus()
78- curMsgEl = el
7982 }
8083 }
app/page/calendar.jsView
@@ -56,9 +56,9 @@
5656 Calendar(state, actions),
5757 Events(state, api)
5858 ])
5959
60- page.scroll = (i) => scroll(state.range, i)
60 + page.keyboardScroll = (i) => scroll(state.range, i)
6161
6262 return page
6363 }
6464
app/page/channel.jsView
@@ -69,9 +69,9 @@
6969 container
7070 ])
7171
7272 // TODO better scroll hack for keyboard shortcuts
73- page.scroll = container.scroll
73 + page.keyboardScroll = container.keyboardScroll
7474
7575 return page
7676 }
7777 }
app/page/postRank.jsView
@@ -150,9 +150,9 @@
150150 const { container, content } = api.app.html.scroller({ prepend: top })
151151
152152 function draw () {
153153 // reset
154- container.scroll(0)
154 + container.keyboardScroll(0)
155155 content.innerHTML = ''
156156
157157 getPosts(channelPostBoost, friendPostBoost, friendVoteBoost, friendCommentBoost, threshold,
158158 (msgs) => {
app/page/posts.jsView
@@ -89,9 +89,9 @@
8989 if (state.sort === BY_START) page = PageByStart(state)
9090
9191 page.title = '/posts'
9292 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'))
9494 return page
9595 })
9696
9797 function PageByUpdate (state) {
app/page/private.jsView
@@ -46,24 +46,24 @@
4646 content.recps = [id, ...(content.mentions || [])]
4747 .filter(m => ref.isFeed(typeof m === 'string' ? m : m.link))
4848 return content
4949 },
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.' }
5151 )
5252 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
5353 const { container, content } = api.app.html.scroller({ prepend: [ composer, filterMenu ] })
5454
5555 function draw () {
5656 resetFeed({ container, content })
5757
5858 pull(
59- pullPrivate({old: false, live: true}),
59 + pullPrivate({ old: false, live: true }),
6060 filterDownThrough(),
6161 Scroller(container, content, api.message.html.render, true, false)
6262 )
6363
6464 pull(
65- pullPrivate({reverse: true}),
65 + pullPrivate({ reverse: true }),
6666 filterUpThrough(),
6767 Scroller(container, content, api.message.html.render, false, false)
6868 )
6969 }
@@ -75,12 +75,12 @@
7575
7676 function pullPrivate (opts) {
7777 const query = [{
7878 $filter: {
79- timestamp: {$gt: 0},
79 + timestamp: { $gt: 0 },
8080 value: {
8181 content: {
82- recps: {$truthy: true}
82 + recps: { $truthy: true }
8383 }
8484 }
8585 }
8686 }]
app/sync/catch-keyboard-shortcut.jsView
@@ -48,9 +48,9 @@
4848 const currentPage = tabs.currentPage()
4949 // TODO change this scroll API - it seems some pages
5050 // (e.g. Dark Crystal Index) has scroll defined and expect an object
5151 if (currentPage) {
52- scroll = currentPage.scroll
52 + scroll = currentPage.keyboardScroll || noop
5353 } else {
5454 scroll = noop
5555 }
5656

Built with git-ssb-web