Skip to content

Instantly share code, notes, and snippets.

@Gergling
Created February 11, 2015 22:41
Show Gist options
  • Save Gergling/eb63498007e2756fade8 to your computer and use it in GitHub Desktop.
Save Gergling/eb63498007e2756fade8 to your computer and use it in GitHub Desktop.
A function designed to pick out the (x, y) co-ordinates from absolute, arbitrarily positioned, potentially-overlapping 'tiles'. Originally used to handle mouse interaction with isometrically-positioned tiles.
var tileOp = function ($event, fnc, always) {
var el = $element.find('.isometric-grid'),
x = $event.clientX - el.offset().left + $window.scrollX,
y = $event.clientY - el.offset().top + $window.scrollY;
$scope.tiles.forEach(function (tile) {
always(tile);
if (tile.boundsCheck(x - tile.left(), y - tile.top())) {
fnc(tile);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment