UNPKG

tapspace

Version:

A zoomable user interface lib for web apps

31 lines (26 loc) 709 B
module.exports = (pointers, plane) => { // Transit pointer coordinates on page onto affine root. // // Parameters // pointers // a map: id -> {x,y}, where x and y are in page coordinates. // plane // the affine root plane, the viewport. // // Return // object, a map: id -> {x, y} // // Reusable function that converts page coords to affine points, // but reads the conversion arguments from the DOM only once. const atPage = plane.atPageFn() // Transited pointers const result = {} let k, p const keys = Object.keys(pointers) while (keys.length > 0) { k = keys.pop() p = pointers[k] result[k] = atPage(p.x, p.y).point } return result }