pure-canvas
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "pure-canvas", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "TODO", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -51,14 +51,20 @@ import Node, {Bounds, Point} from './Node'; | ||
private emitHitEvent(name: string, event: MouseEvent): void { | ||
const point = this.eventToElementCoordinate(event); | ||
const results = this.tree | ||
.search({minX: point.x, minY: point.y, maxX: point.x, maxY: point.y}) | ||
.sort((a: IndexedNode, b: IndexedNode) => b.zIndex - a.zIndex) | ||
.map((indexedNode: IndexedNode) => { | ||
const untransformedPoint = indexedNode.transformers.reduceRight((point: Point, transformer: Transformer) => transformer.untransform(point), point); | ||
return indexedNode.node.intersection(untransformedPoint); | ||
}) | ||
.filter(Boolean); | ||
this.emit(name, results[0], event); | ||
let didSearch: boolean = false; | ||
let result: Node = undefined; | ||
this.emit(name, () => { | ||
if (!didSearch) { | ||
const point = this.eventToElementCoordinate(event); | ||
const results = this.tree | ||
.search({minX: point.x, minY: point.y, maxX: point.x, maxY: point.y}) | ||
.sort((a: IndexedNode, b: IndexedNode) => b.zIndex - a.zIndex) | ||
.map((indexedNode: IndexedNode) => { | ||
const untransformedPoint = indexedNode.transformers.reduceRight((point: Point, transformer: Transformer) => transformer.untransform(point), point); | ||
return indexedNode.node.intersection(untransformedPoint); | ||
}) | ||
.filter(Boolean); | ||
result = results[0]; | ||
didSearch = true; | ||
} | ||
return result; | ||
}, event); | ||
} | ||
@@ -65,0 +71,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1553
142611