Append more div the list element, check loading on scroll.
Install with npm:
$ npm install more-mobile
Install with component(1):
$ component install chemzqm/more
load
is emitted after callback called.
var more = require('more')
var el = document.querySelector('ul')
var times = 0
more(el, function() {
return new Promise(function(resolve, reject) {
var arr
// fetch the list
if (err)return reject()
if (arr.length) {
more.disable() //disable loading
}
resolve()
})
})
})
Insert more
after list el
, call the callback with a function when more div could be visible(or return promise)
scrollable is Object (could be element or other object) which emit scroll
event, it default to el.parentNode
, could also be window
Disable more loading.
Remove inserted div and unbind events
Force more start loading data without scroll event fired (will not load if it's loading or disabled)
Return promise
MIT