-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
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
Need Help! #6
Comments
You would have to store the x, y, width, and height of every box and use a collision detection algorithm. |
I have that values stored and a key which is unique identifier is also there, I am having issues with collision detection algorithm!! I want to identify uniquely each rectangles. Thanks |
@aminshuzo If you add the following code to the demo, you can listen for click events and check which box was clicked on. demo.jsDemo = {
// ...
run: function() {
// ...
$(Demo.el.canvas).click(function(e) {
var x = e.offsetX;
var y = e.offsetY;
for (var i = 0; i < blocks.length; i++) {
var b = blocks[i];
if (Demo.inBounds(b, x, y)) {
alert('Found block at: (' + b.fit.x + ',' + b.fit.y + ') - ' + b.w + 'x' + b.h);
break;
}
}
});
},
inBounds: function(block, x, y) {
var x1 = block.fit.x;
var y1 = block.fit.y;
var x2 = x1 + block.w;
var y2 = y1 + block.h;
return x >= x1 && x <= x2 && y >= y1 && y <= y2;
},
// ...
}; |
Ryankane, I am still facing the same issue please help me out to find some way out. According to your code, few of the boxes are clickable and few of them are not. run: function () {
|
Hey thanks for this wonderful piece of work,
I am using 2d bin package as dashboard, i want to make it drill down, would you please help me out, how could i add click event on every boxes?
Thanks.
The text was updated successfully, but these errors were encountered: