Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

Any way to trigger via boolean instead of timer? #16

Closed
ghost opened this issue Jun 7, 2016 · 2 comments
Closed

Any way to trigger via boolean instead of timer? #16

ghost opened this issue Jun 7, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 7, 2016

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.

@changyushun
Copy link

jQuery Plugin:

  1. add local var and public method
    var isStop = false; //console.log(isStop); $.fn.fakeLoader.stop = function () { isStop = true; //console.log('call outside ' + isStop); };
  2. check timeToHide is 0 or not, if 0 mean set interval timer to check 'isStop' value
    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();

@ghost
Copy link
Author

ghost commented Nov 8, 2016

Thanks @changyushun !

@ghost ghost closed this as completed Nov 8, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant