element-measurer
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -88,3 +88,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
\*********************************/ | ||
/*! exports provided: default */ | ||
/*! exports provided: ElementMeasurer, default */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
@@ -94,4 +94,5 @@ | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElementMeasurer", function() { return ElementMeasurer; }); | ||
/** | ||
* Element measurer. | ||
* The library class that can measures size of element. | ||
* | ||
@@ -103,4 +104,5 @@ * @export | ||
/** | ||
* constructor | ||
* @param target | ||
* Creates an instance of ElementMeasurer. | ||
* @param {AllowedTarget} [target=document.documentElement] | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -114,3 +116,6 @@ function ElementMeasurer(target) { | ||
* Returns whether target is document or html element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {boolean} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -127,3 +132,6 @@ get: function () { | ||
* Returns inner width of an element in pixels. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -141,3 +149,6 @@ get: function () { | ||
* Returns inner height of an element in pixels. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -155,3 +166,5 @@ get: function () { | ||
* Gets or sets the number of pixels that an element's content is scrolled vertically. | ||
* @return | ||
* | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -175,3 +188,5 @@ get: function () { | ||
* Gets or sets the number of pixels that an element's content is scrolled to the left. | ||
* @return | ||
* | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -195,3 +210,6 @@ get: function () { | ||
* Returns the width of the entire content of an element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -207,3 +225,6 @@ get: function () { | ||
* Returns the height of the entire content of an element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -219,3 +240,6 @@ get: function () { | ||
* Returns maximum top scroll offset possible for the element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -231,3 +255,6 @@ get: function () { | ||
* Returns maximum left scroll offset possible for the element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -242,4 +269,6 @@ get: function () { | ||
* Set target element. | ||
* @param val | ||
* @return | ||
* | ||
* @param {AllowedTarget} val target element. | ||
* @returns {this} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -264,2 +293,4 @@ ElementMeasurer.prototype.setTarget = function (val) { | ||
* @see https://stackoverflow.com/questions/442404/retrieve-the-position-x-y-of-an-html-element#answer-442474 | ||
* @returns {Offsets} {top, left} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -279,2 +310,3 @@ ElementMeasurer.prototype.getOffset = function () { | ||
}()); | ||
/* harmony default export */ __webpack_exports__["default"] = (ElementMeasurer); | ||
@@ -281,0 +313,0 @@ |
@@ -1,1 +0,5 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ElementMeasurer=t():e.ElementMeasurer=t()}(this,function(){return function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="./src/element-measurer.ts")}({"./src/element-measurer.ts":function(e,t,r){"use strict";r.r(t);var o=function(){function e(e){void 0===e&&(e=document.documentElement),this.setTarget(e)}return Object.defineProperty(e.prototype,"isDocument",{get:function(){return this.target===document.documentElement||this.target===document.body},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"clientWidth",{get:function(){return this.isDocument?window.innerWidth:this.target.getBoundingClientRect().width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"clientHeight",{get:function(){return this.isDocument?window.innerHeight:this.target.getBoundingClientRect().height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollTop",{get:function(){return this.isDocument?window.pageYOffset:this.target.scrollTop},set:function(e){this.isDocument?window.scrollTo(this.scrollLeft,e):this.target.scrollTop=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollLeft",{get:function(){return this.isDocument?window.pageXOffset:this.target.scrollLeft},set:function(e){this.isDocument?window.scrollTo(e,this.scrollTop):this.target.scrollLeft=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollWidth",{get:function(){return this.target.scrollWidth},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollHeight",{get:function(){return this.target.scrollHeight},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollTop",{get:function(){return this.scrollHeight-this.clientHeight},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollLeft",{get:function(){return this.scrollWidth-this.clientWidth},enumerable:!0,configurable:!0}),e.prototype.setTarget=function(e){if(e instanceof HTMLElement||e instanceof Element)this.target=e;else if(e===window||e===document)this.target=document.documentElement;else{if("string"!=typeof e)throw new TypeError("Target value is not correct type.");this.target=document.querySelector(e)}return this},e.prototype.getOffset=function(){for(var e=this.target,t=0,r=0;e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop);)r+=e.offsetLeft-e.scrollLeft,t+=e.offsetTop-e.scrollTop,e=e.offsetParent;return{top:t,left:r}},e}();t.default=o}})}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ElementMeasurer=t():e.ElementMeasurer=t()}(this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="./src/element-measurer.ts")}({"./src/element-measurer.ts": | ||
/*!*********************************!*\ | ||
!*** ./src/element-measurer.ts ***! | ||
\*********************************/ | ||
/*! exports provided: ElementMeasurer, default */function(e,t,r){"use strict";r.r(t),r.d(t,"ElementMeasurer",function(){return n});var n=function(){function e(e){void 0===e&&(e=document.documentElement),this.setTarget(e)}return Object.defineProperty(e.prototype,"isDocument",{get:function(){return this.target===document.documentElement||this.target===document.body},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"clientWidth",{get:function(){return this.isDocument?window.innerWidth:this.target.getBoundingClientRect().width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"clientHeight",{get:function(){return this.isDocument?window.innerHeight:this.target.getBoundingClientRect().height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollTop",{get:function(){return this.isDocument?window.pageYOffset:this.target.scrollTop},set:function(e){this.isDocument?window.scrollTo(this.scrollLeft,e):this.target.scrollTop=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollLeft",{get:function(){return this.isDocument?window.pageXOffset:this.target.scrollLeft},set:function(e){this.isDocument?window.scrollTo(e,this.scrollTop):this.target.scrollLeft=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollWidth",{get:function(){return this.target.scrollWidth},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollHeight",{get:function(){return this.target.scrollHeight},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollTop",{get:function(){return this.scrollHeight-this.clientHeight},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollLeft",{get:function(){return this.scrollWidth-this.clientWidth},enumerable:!0,configurable:!0}),e.prototype.setTarget=function(e){if(e instanceof HTMLElement||e instanceof Element)this.target=e;else if(e===window||e===document)this.target=document.documentElement;else{if("string"!=typeof e)throw new TypeError("Target value is not correct type.");this.target=document.querySelector(e)}return this},e.prototype.getOffset=function(){for(var e=this.target,t=0,r=0;e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop);)r+=e.offsetLeft-e.scrollLeft,t+=e.offsetTop-e.scrollTop,e=e.offsetParent;return{top:t,left:r}},e}();t.default=n}})}); |
{ | ||
"name": "element-measurer", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "The javascript library class for measures size of Element.", | ||
@@ -32,13 +32,13 @@ "main": "dist/element-measurer.js", | ||
"@types/chai-as-promised": "^7.1.0", | ||
"@types/mocha": "^2.2.48", | ||
"@types/puppeteer": "^1.1.0", | ||
"@types/mocha": "^5.0.0", | ||
"@types/puppeteer": "^1.2.0", | ||
"chai": "^4.1.2", | ||
"chai-as-promised": "^7.1.1", | ||
"mocha": "^5.0.4", | ||
"puppeteer": "^1.1.1", | ||
"mocha": "^5.0.5", | ||
"puppeteer": "^1.2.0", | ||
"source-map-loader": "^0.2.3", | ||
"ts-loader": "^4.0.1", | ||
"typescript": "^2.7.2", | ||
"webpack": "^4.1.1", | ||
"webpack-cli": "^2.0.12", | ||
"ts-loader": "^4.1.0", | ||
"typescript": "^2.8.1", | ||
"webpack": "^4.4.1", | ||
"webpack-cli": "^2.0.13", | ||
"webpack-merge": "^4.1.2", | ||
@@ -45,0 +45,0 @@ "webpack-notifier": "^1.6.0" |
@@ -1,4 +0,12 @@ | ||
declare type ArrowToTarget = HTMLElement|Element|Window|Document|string; | ||
export as namespace ElementMeasurer; | ||
declare interface Offsets { | ||
export type AllowedTarget = HTMLElement|Element|Window|Document|string; | ||
/** | ||
* Expressions top and left offset values. | ||
* | ||
* @export | ||
* @interface Offsets | ||
*/ | ||
export interface Offsets { | ||
top: number; | ||
@@ -9,3 +17,3 @@ left: number; | ||
/** | ||
* Element measurer. | ||
* The library class that can measures size of element. | ||
* | ||
@@ -15,3 +23,3 @@ * @export | ||
*/ | ||
export default class ElementMeasurer { | ||
export class ElementMeasurer { | ||
target: HTMLElement; | ||
@@ -39,13 +47,16 @@ | ||
/** | ||
* constructor | ||
* @param target | ||
* Creates an instance of ElementMeasurer. | ||
* @param {AllowedTarget} [target=document.documentElement] | ||
* @memberof ElementMeasurer | ||
*/ | ||
constructor(target?: ArrowToTarget); | ||
constructor(target?: AllowedTarget); | ||
/** | ||
* Set target element. | ||
* @param val | ||
* @return | ||
* | ||
* @param {AllowedTarget} val target element. | ||
* @returns {this} | ||
* @memberof ElementMeasurer | ||
*/ | ||
setTarget(val: ArrowToTarget): this; | ||
setTarget(val: AllowedTarget): this; | ||
@@ -55,4 +66,8 @@ /** | ||
* @see https://stackoverflow.com/questions/442404/retrieve-the-position-x-y-of-an-html-element#answer-442474 | ||
* @returns {Offsets} {top, left} | ||
* @memberof ElementMeasurer | ||
*/ | ||
getOffset(): Offsets; | ||
} | ||
export default ElementMeasurer; |
@@ -1,4 +0,10 @@ | ||
type ArrowToTarget = HTMLElement|Element|Window|Document|string; | ||
export type AllowedTarget = HTMLElement|Element|Window|Document|string; | ||
interface Offsets { | ||
/** | ||
* Expressions top and left offset values. | ||
* | ||
* @export | ||
* @interface Offsets | ||
*/ | ||
export interface Offsets { | ||
top: number; | ||
@@ -9,3 +15,3 @@ left: number; | ||
/** | ||
* Element measurer. | ||
* The library class that can measures size of element. | ||
* | ||
@@ -15,10 +21,11 @@ * @export | ||
*/ | ||
export default class ElementMeasurer { | ||
export class ElementMeasurer { | ||
target: HTMLElement; | ||
/** | ||
* constructor | ||
* @param target | ||
* Creates an instance of ElementMeasurer. | ||
* @param {AllowedTarget} [target=document.documentElement] | ||
* @memberof ElementMeasurer | ||
*/ | ||
constructor(target: ArrowToTarget = document.documentElement) { | ||
constructor(target: AllowedTarget = document.documentElement) { | ||
this.setTarget(target); | ||
@@ -29,3 +36,6 @@ } | ||
* Returns whether target is document or html element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {boolean} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -39,3 +49,6 @@ get isDocument(): boolean { | ||
* Returns inner width of an element in pixels. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -50,3 +63,6 @@ get clientWidth(): number { | ||
* Returns inner height of an element in pixels. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -61,3 +77,5 @@ get clientHeight(): number { | ||
* Gets or sets the number of pixels that an element's content is scrolled vertically. | ||
* @return | ||
* | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -78,3 +96,5 @@ get scrollTop(): number { | ||
* Gets or sets the number of pixels that an element's content is scrolled to the left. | ||
* @return | ||
* | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -95,3 +115,6 @@ get scrollLeft(): number { | ||
* Returns the width of the entire content of an element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -104,3 +127,6 @@ get scrollWidth(): number { | ||
* Returns the height of the entire content of an element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -113,3 +139,6 @@ get scrollHeight(): number { | ||
* Returns maximum top scroll offset possible for the element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -122,3 +151,6 @@ get maxScrollTop(): number { | ||
* Returns maximum left scroll offset possible for the element. | ||
* @return | ||
* | ||
* @readonly | ||
* @type {number} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -131,6 +163,8 @@ get maxScrollLeft(): number { | ||
* Set target element. | ||
* @param val | ||
* @return | ||
* | ||
* @param {AllowedTarget} val target element. | ||
* @returns {this} | ||
* @memberof ElementMeasurer | ||
*/ | ||
setTarget(val: ArrowToTarget): this { | ||
setTarget(val: AllowedTarget): this { | ||
if (val instanceof HTMLElement || val instanceof Element) { | ||
@@ -151,2 +185,4 @@ this.target = val as HTMLElement; | ||
* @see https://stackoverflow.com/questions/442404/retrieve-the-position-x-y-of-an-html-element#answer-442474 | ||
* @returns {Offsets} {top, left} | ||
* @memberof ElementMeasurer | ||
*/ | ||
@@ -167,1 +203,3 @@ getOffset(): Offsets { | ||
} | ||
export default ElementMeasurer; |
Sorry, the diff of this file is not supported yet
63105
872