UNPKG

tapspace

Version:

A zoomable user interface lib for web apps

28 lines (23 loc) 703 B
const Component = require('../../components/Component') const findAffineAncestor = Component.findAffineAncestor module.exports = (pointers) => { // Find affine target for the given set of sensed pointers. // Basically picks the first target. // // Parameters: // pointers // a map from pointer id to {x,y,target} // // Return // a Component // const ids = Object.keys(pointers) if (ids.length > 0) { const firstId = ids[0] const firstPointer = pointers[firstId] const firstTarget = firstPointer.target return findAffineAncestor(firstTarget) } // If no pointers, it is an error throw new Error('cannot find target from empty set of pointers.') }