UNPKG

738 BJavaScriptView Raw
1var Scroller = require('../')
2var pull = require('pull-stream')
3var h = require('hyperscript')
4
5var content = h('div')
6var scroller = h('div', {
7 style: {
8 //must set overflow-y to scroll for this to work.
9 'overflow-y': 'scroll',
10 //and cause this element to not stretch.
11 //this can also be achived using flexbox column.
12 position: 'fixed', bottom:'0px', top: '0px',
13 'margin-left': 'auto',
14 'margin-right': 'auto',
15 width: '600px'
16 }
17 }, content)
18
19 //provide a render function that returns an html element.
20 function render (n) {
21 return h('h1', n.toString())
22 }
23
24 pull(
25 pull.infinite(),
26 Scroller(scroller, content, render)
27 )
28
29document.body.appendChild(scroller)
30
31
32
33
34
35
36
37