Sha256: ec3651de0bea4d76f0bc058daef4ec15114c13d72e136be68b6fd9c7b6c231c1

Contents?: true

Size: 1.21 KB

Versions: 375

Compression:

Stored size: 1.21 KB

Contents

/* global dom */

/**
 * Get the coordinates of the element passed into the function relative to the document
 * @method getElementCoordinates
 * @memberof axe.commons.dom
 * @instance
 * @param {HTMLElement} element The HTMLElement
 * @return {elementObj} elementObj Returns a `Object` with the following properties, which
 * each hold a value representing the pixels for each of the
 */
/**
 * @typedef elementObj
 * @type {Object}
 * @property {Number} top The top coordinate of the element
 * @property {Number} right The right coordinate of the element
 * @property {Number} bottom The bottom coordinate of the element
 * @property {Number} left The left coordinate of the element
 * @property {Number} width The width of the element
 * @property {Number} height The height of the element
 */
dom.getElementCoordinates = function(element) {
	'use strict';

	var scrollOffset = dom.getScrollOffset(document),
		xOffset = scrollOffset.left,
		yOffset = scrollOffset.top,
		coords = element.getBoundingClientRect();

	return {
		top: coords.top + yOffset,
		right: coords.right + xOffset,
		bottom: coords.bottom + yOffset,
		left: coords.left + xOffset,
		width: coords.right - coords.left,
		height: coords.bottom - coords.top
	};
};

Version data entries

375 entries across 375 versions & 1 rubygems

Version Path
govuk_publishing_components-30.4.1 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-30.4.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-30.3.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-30.2.1 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-30.2.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-30.1.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-30.0.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.15.3 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.15.2 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.15.1 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.15.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.14.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.13.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.12.1 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.12.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.11.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.10.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.9.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.8.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js
govuk_publishing_components-29.7.0 node_modules/axe-core/lib/commons/dom/get-element-coordinates.js