Closed ghost closed 7 years ago
jQuery Plugin:
var isStop = false; //console.log(isStop); $.fn.fakeLoader.stop = function () { isStop = true; //console.log('call outside ' + isStop); };
if (settings.timeToHide > 0) { setTimeout(function () { $(el).fadeOut(); }, settings.timeToHide); } else { var timer = setInterval(function () { //console.log(isStop); if (isStop) { $(el).fadeOut(); clearInterval(timer); } }, 200); }
finally HTML code:
var loader = $('#fakeLoader'); // show loader.fakeLoader(); // disapear loader.fakeLoader.stop();
Thanks @changyushun !
I'm looking for a way to trigger it based on a boolean value.
Sometimes the time taken to execute an action differs, so I'd prefer to be able to set a flag to display whether to display the loader or not.