Created
February 11, 2015 22:41
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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