'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = readMeasurements;
var _jquery = require('jquery');
var _jquery2 = _interopRequireDefault(_jquery);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var $window = (0, _jquery2.default)(window);
function readElemMeasurements(elem) {
return {
offset: elem.offset(),
width: elem.outerWidth(),
height: elem.outerHeight()
};
}
function readViewportMeasurements() {
return {
scrollTop: $window.scrollTop(),
scrollLeft: $window.scrollLeft(),
height: $window.height(),
width: $window.width()
};
}
function getViewportBounds(viewport) {
return {
left: viewport.scrollLeft,
right: viewport.scrollLeft + viewport.width,
top: viewport.scrollTop,
bottom: viewport.scrollTop + viewport.height
};
}
function readMeasurements(element, target) {
var viewport = readViewportMeasurements();
var bounds = getViewportBounds(viewport);
var measurements = {
element: readElemMeasurements(element),
target: readElemMeasurements(target),
viewport: viewport,
bounds: bounds
};
return measurements;
}