// create some boxes
var _setTimeout = setTimeout;
setTimeout = function () {
if (Array.isArray(arguments[0])) {
var a = arguments[0].map(function (e) {
return setTimeout(e, this).bind(arguments[1])
});
a.cancel = function () {
this.forEach(function (e) {
e.cancel()
})
};
a.then = function () {
this.every(function (e) {
return e.done;
})
};
a.bounce = function (t) {
return this.map(function (e) {
e.bounce(t);
});
};
return a;
} else {
var a = Object.create(null);
a.function = arguments[0];
a.delay = arguments[1];
a._then =null;
a._pointer = _setTimeout.call(null, function () {
a.function();
if(a._then)a._then();
}.bind(a), a.delay);
a.cancel = function () {
clearTimeout(this._pointer);
return this;
};
a.then = function (f) {
this._then = f.bind(this);
return this;
};
a.bounce = function (t) {
clearTimeout(this._pointer);
return setTimeout(a.function, t);
};
a.loop = function () {
var _loop = function(){setTimeout(function() {
this.function();
}.bind(this), this.delay).then(_loop)}.bind(this);
return _loop;
}
return a;
}
};
for (var i = 0,c = 0; i < 1000;c+=20, i ++ ){
$('<div class="box" />').appendTo('#outer').css({
left:c%200,
top: Math.floor(c/200)*20
});
}
// this function should (did not enough testing) return all elements at a given
// point in the order of top to bottom.
var elementsFromPoint = function (root, x, y) {
var _root = document.elementFromPoint(x,y).parentElement;
if(!!_root)
root=_root;
var result = [], i = 0, lim =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.