Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pulltorefresh.js - Disable temporarily

I am using this PullToRefresh plugin:

https://github.com/BoxFactura/pulltorefresh.js#api

It works well but I have a popup on my page with div inline scroll. The problem is that when I want to scroll up (in the div) the PullToRefresh is triggered. Is it possible to "delete" or to temporarily disable the PullToRefresh when my popup is opened?

PullToRefresh.init({
    mainElement: 'body',
    onRefresh: function(){
        refreshAll();
    }
});

edit: delete PullToRefresh; // does not work

edit2: https://github.com/BoxFactura/pulltorefresh.js/blob/master/dist/pulltorefresh.js

like image 529
Peter Avatar asked Jul 31 '17 23:07

Peter


1 Answers

PullToRefresh.init() will return an object with a destroy() function as callback: https://github.com/BoxFactura/pulltorefresh.js/blob/master/dist/pulltorefresh.js#L326

var refresher = PullToRefresh.init({
    mainElement: 'body',
    onRefresh: function(){
        refreshAll();
    }
});

// destroy the PullToRefresh EventListeners when you open your popup
refresher.destroy()

There's also an open Github issue about improving the way to destroy this library after initialization: https://github.com/BoxFactura/pulltorefresh.js/issues/22

like image 107
Tom Van Rompaey Avatar answered Oct 22 '22 17:10

Tom Van Rompaey