Sha256: a212967d103f0733ba2b3ec39bca56840fd23b91ef50b9a54981f26792f3d655

Contents?: true

Size: 867 Bytes

Versions: 104

Compression:

Stored size: 867 Bytes

Contents

/* global dom */
/*eslint complexity: ["error", 14]*/
/**
 * Get the scroll offset of the document passed in
 * @method getScrollOffset
 * @memberof axe.commons.dom
 * @instance
 * @param {Document} element The element to evaluate, defaults to document
 * @return {Object} Contains the attributes `x` and `y` which contain the scroll offsets
 */
dom.getScrollOffset = function(element) {
	'use strict';

	if (!element.nodeType && element.document) {
		element = element.document;
	}

	// 9 === Node.DOCUMENT_NODE
	if (element.nodeType === 9) {
		var docElement = element.documentElement,
			body = element.body;

		return {
			left:
				(docElement && docElement.scrollLeft) || (body && body.scrollLeft) || 0,
			top: (docElement && docElement.scrollTop) || (body && body.scrollTop) || 0
		};
	}

	return {
		left: element.scrollLeft,
		top: element.scrollTop
	};
};

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
govuk_publishing_components-21.16.3 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.16.2 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.16.1 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.16.0 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.15.2 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.15.1 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.15.0 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.14.0 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.13.5 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.13.4 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.13.3 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.13.2 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.13.1 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.13.0 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.12.0 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.11.0 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.10.0 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.9.0 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.8.1 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js
govuk_publishing_components-21.8.0 node_modules/axe-core/lib/commons/dom/get-scroll-offset.js