ember-mobile-menu
Version:
A draggable sidebar menu for Ember.
40 lines (38 loc) • 1.05 kB
JavaScript
/**
* Normalizes coordinates in the passed TouchData to the BoundingClientRect of the passed element
*
* @function normalizeCoordinates
* @param e {Object} TouchData as generated by ember-mobile-core
* @param bcr {DOMRect} The DOMRect of the element to which the coordinates need to be normalized.
* @return {Object} Returns a TouchData object
* @private
*/
function normalizeCoordinates(e, bcr) {
return {
...e,
initial: {
...e.initial,
x: e.initial.x - bcr.x,
y: e.initial.x - bcr.x
},
current: {
...e.current,
x: e.current.x - bcr.x,
y: e.current.x - bcr.x
}
};
}
function scaleCorrection(e, scaleX, scaleY) {
// TODO: convert rest of API
return {
...e,
current: {
...e.current,
distance: e.current.distance / ((scaleX + scaleY) / 2),
distanceX: e.current.distanceX / scaleX,
distanceY: e.current.distanceY / scaleY
}
};
}
export { normalizeCoordinates as default, scaleCorrection };
//# sourceMappingURL=normalize-coordinates.js.map