report location of hex coordinate on tap

This commit is contained in:
Gavin McDonald
2016-03-05 20:48:18 -05:00
parent 7bb085557e
commit 839971a8c0
3 changed files with 28 additions and 25 deletions

View File

@@ -20,8 +20,8 @@ export default class Tessellate {
constructor(settings) {
['tap', 'draw', 'drawMap', 'move', 'zoom'].map(method => {this[method] = this[method].bind(this)});
this.tapCB = settings.tap || utils.noop;
this.drawCB = settings.draw || utils.noop;
this.clickCB = settings.click || utils.noop;
this.element = document.querySelector(settings.element);
this.sketch = new Sketch({
@@ -48,7 +48,16 @@ export default class Tessellate {
}
tap(event) {
this.clickCB(event);
let point = new Point(event.offsetX, event.offsetY);
let hex = this.xyz.pixelToHex(point);
let tap = {
event,
point,
hex
};
this.tapCB(tap);
}
move(event) {