We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include alongside ready() and load():
ready()
load()
wait = function(ms) { return new Promise(function(resolve) { setTimeout(resolve, ms || 1); }); }; tick = function(callback) { var state, ticker, control, t1s, t2s; state = {active: true, iteration: 0}; ticker = function(extra) { state.iteration++; callback(control); state.active && extra !== true && requestAnimationFrame(ticker); }; requestAnimationFrame(ticker); t1s = setTimeout(ticker, 1000, true); t2s = setTimeout(ticker, 2000, true); control = { state: state, stop: function() { state.active = false; clearTimeout(t1s); clearTimeout(t2s); } }; return control; }; normalize = function(str, limit = 0) { str = str.trim().toLowerCase().replace(/[^a-z0-9\-]+/ig, '-').replace(/(^\-+|\-+$)/g, '').replace(/\-+/g, '-'); if (limit) { str = str.split('-').slice(0, limit).join('-'); } return str; }; xhr = function(method, url, data) { return new Promise(function(resolve, reject) { var req = new XMLHttpRequest; req.open(method, url, true); if (method.toUpperCase() == 'POST') { req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); } req.onload = function(e) { resolve(this); }; req.onerror = function(e) { reject(this); }; req.send(data); }); }; listen = function(targets, callback) { var curs; if ( targets.constructor != Array ) { targets = [targets]; } ready(function() { curs = targets.map(fn => fn()); callback([]); }); tick(function() { if ( !curs ) return; var news = targets.map(fn => fn()); var diffs = []; curs.forEach((old, i) => { if ( old !== news[i] ) { diffs.push(i); } }); if ( diffs.length) { // console.log('CHANGES', curs, news); callback(diffs); curs = news; } }); };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Include alongside
ready()
andload()
:The text was updated successfully, but these errors were encountered: