Collision loop of doom

I'm using Fabric and JS for a project I'm working on. Fabric models the objects within the canvas as an array.

I have a collision detection method that iterates through the canvas array and determines when a collision with a new object has been detected. The detection is functional and working. I essentially have 5 blocks on he screen with another on a downward path. As it touches them they change colour.

I'm printing the names of each of the blocks it touches to the console and to screen. What I'd like is for it to display the most recent block that has been touched.

The problem is that one block is always always missed out. If the namers were colours such as:


The output is always R, G, B, Y - occasionally the one that is missed will change, typically it's Pink or Blue.

The code I'm using was:

function detectCollision(target) {


    canvas.forEachObject(function(obj) {
        if (obj === target) return;
        if (obj != target && target.intersectsWithObject(obj)){

            obj.opacity = 0.5;
            console.log("Collision with Obj: " +obj.label);
            return obj;
            obj.opacity = 1;

I saw "was" as I've tried various other things such as using a while loop and also using an array so that when an object is touched it is added to the array and then a check is performed on that instead but still the same results.

It's extremely frustrating and I simply cannot see what the problem is. Any help is hugely appreciated. Thanks.


For anyone that happens to come across this :

The problem was not with the loop, the array or any of the methods. The block that was being missed was under another by a pixel or so and the intersect method wasn't running a check on this so it was being skipped. The block that was being missed changed from time to time because of the changes I was making to the order of them.

Need Your Help

Problems reading csv-File

python pandas

I am having massive issues reading an csv which I can provide upon request (since I don't know how to upload here). It has the dot . as thousands separator which makes issues as stated before.

What console output commands are available in Erlang?


What console output commands are available in Erlang?