After getting advice to use this "style" of collision detection instead of jQuery Collision -
function isCollide(a, b) {
return !(
((a.y + a.height) < (b.y)) ||
(a.y > (b.y + b.height)) ||
((a.x + a.width) < b.x) ||
(a.x > (b.x + b.width))
);
}
I am trying it but am having an issue: the "else" part that is suppose to happen when the collision occurs is happening instantaneously for some reason, as soon as the page is loaded.
Here is the Fiddle.
And here is the function:
function homePage() {
//initial animation
for (var i=0; i<links.length; i++) {
//animate links
$(links[i]).animate({
top: '0'
}, {
duration: 2000*(Math.random()*(1.1)+1),
easing: 'easeOutBounce',
step: function() {
if ($(links[i]).x > ($(".footer").x + $(".footer").width)
|| $(links[i]).y > ($(".footer").y + $(".footer").height)
|| ($(links[i]).x + $(links[i]).width) < $(".footer").x
|| ($(links[i]).y + $(links[i]).height) < $(".footer").y)
{
$(links[i]).css("background-color", "yellow");
}
else
{
$(links[i]).css("background-color", "red");
}
}
})
}
}