A Pressing Matter (#11)
This commit is contained in:
@@ -35,10 +35,14 @@ const TILES = {
|
||||
const DEFAULTS = {
|
||||
tile: HEX,
|
||||
board: HEX,
|
||||
tap: utils.noop,
|
||||
draw: utils.noop,
|
||||
orientation: FLAT,
|
||||
negativeTiles: true,
|
||||
|
||||
tap: utils.noop,
|
||||
pressStart: utils.noop,
|
||||
press: utils.noop,
|
||||
|
||||
draw: utils.noop,
|
||||
};
|
||||
|
||||
function selectCartographer(board, orientation) {
|
||||
@@ -72,6 +76,9 @@ export class Tessellate {
|
||||
[
|
||||
'checkSettings',
|
||||
'tap',
|
||||
'doubletap',
|
||||
'pressStart',
|
||||
'press',
|
||||
'move',
|
||||
'zoom',
|
||||
'pixelToTile',
|
||||
@@ -87,14 +94,15 @@ export class Tessellate {
|
||||
draw: this.draw
|
||||
});
|
||||
|
||||
this.onTap = new OnTap({
|
||||
this.onTap = new OnTap(Object.assign({
|
||||
element: this.settings.element,
|
||||
tap: this.tap,
|
||||
doubletap: this.doubletap,
|
||||
hold: this.hold,
|
||||
pressStart: this.pressStart,
|
||||
press: this.press,
|
||||
move: this.move,
|
||||
zoom: this.zoom,
|
||||
});
|
||||
}, funky.pick(this.settings, ['desktopPress', 'moveThreshold', 'doubletapThreshold', 'pressThreshold', 'wheelFactor'])));
|
||||
|
||||
const cartographer = selectCartographer(this.settings.board, this.settings.orientation);
|
||||
this.cartographer = new cartographer(Object.assign({
|
||||
@@ -134,6 +142,7 @@ export class Tessellate {
|
||||
}
|
||||
|
||||
doubletap(event) {
|
||||
console.log('DOUBLETAP', event);
|
||||
let point = new Point(event.offsetX, event.offsetY);
|
||||
let tile = this.cartographer.pixelToTile(point);
|
||||
|
||||
@@ -143,11 +152,10 @@ export class Tessellate {
|
||||
tile
|
||||
};
|
||||
|
||||
console.log('DOUBLETAP');
|
||||
console.log(tap);
|
||||
}
|
||||
|
||||
hold(event) {
|
||||
pressStart(event) {
|
||||
let point = new Point(event.offsetX, event.offsetY);
|
||||
let tile = this.cartographer.pixelToTile(point);
|
||||
|
||||
@@ -157,8 +165,20 @@ export class Tessellate {
|
||||
tile
|
||||
};
|
||||
|
||||
console.log('HOLD');
|
||||
console.log(tap);
|
||||
this.settings.pressStart(tap);
|
||||
}
|
||||
|
||||
press(event) {
|
||||
let point = new Point(event.offsetX, event.offsetY);
|
||||
let tile = this.cartographer.pixelToTile(point);
|
||||
|
||||
let tap = {
|
||||
event,
|
||||
point,
|
||||
tile
|
||||
};
|
||||
|
||||
this.settings.press(tap);
|
||||
}
|
||||
|
||||
move(event) {
|
||||
|
||||
Reference in New Issue
Block a user