Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,29 @@ var doBind = function () {
directive.scrollListener = throttle(doCheck.bind(directive), directive.throttleDelay);
directive.scrollEventTarget.addEventListener('scroll', directive.scrollListener);

//Required for mobile touch scrolling
directive.scrollEventTarget.addEventListener('touchmove', directive.scrollListener);

/*
* Check if scroll was changed
* For cases when mobile user slide touch fast to end of page
* and the "touchmove" event not fire in finish of scroll
*/
var scrollCheckInterval = setInterval(() => {
directive.scrollListener();
}, 1000)

this.vm.$on('hook:beforeDestroy', function () {
directive.scrollEventTarget.removeEventListener('scroll', directive.scrollListener);
directive.scrollEventTarget.removeEventListener('touchmove', directive.scrollListener);
clearInterval(scrollCheckInterval);
});

var disabledExpr = element.getAttribute('infinite-scroll-disabled');
var disabled = false;

if (disabledExpr) {
this.vm.$watch(disabledExpr, function(value) {
this.vm.$watch(disabledExpr, function (value) {
directive.disabled = value;
if (!value && directive.immediateCheck) {
doCheck.call(directive);
Expand Down Expand Up @@ -148,7 +162,7 @@ var doBind = function () {

var eventName = element.getAttribute('infinite-scroll-listen-for-event');
if (eventName) {
directive.vm.$on(eventName, function() {
directive.vm.$on(eventName, function () {
doCheck.call(directive);
});
}
Expand Down