@olton/query
Advanced tools
Comparing version 0.4.17 to 0.4.18
{ | ||
"name": "@olton/query", | ||
"version": "0.4.17", | ||
"version": "0.4.18", | ||
"description": "Query is a minimalist JavaScript library for manipulating with HTML Elements", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -5,13 +5,34 @@ import {undef} from "../helpers/undef.js"; | ||
export const Position = { | ||
offset: function(){ | ||
offset: function(val){ | ||
if (this.length === 0) return | ||
const el = this[0] | ||
return { | ||
top: el.offsetTop, | ||
left: el.offsetLeft, | ||
height: el.offsetHeight, | ||
width: el.offsetWidth, | ||
parent: el.offsetParent | ||
if (undef(val)) { | ||
if (this.length === 0) return undefined; | ||
const rect = this[0].getBoundingClientRect(); | ||
return { | ||
top: rect.top + scrollY, | ||
left: rect.left + scrollX | ||
}; | ||
} | ||
return this.each(function(){ //? | ||
const el = $(this) | ||
let top = val.top, left = val.left | ||
const position = getComputedStyle(this).position | ||
const offset = el.offset(); | ||
if (position === "static") { | ||
el.css("position", "relative"); | ||
} | ||
if (["absolute", "fixed"].indexOf(position) === -1) { | ||
top = top - offset.top; | ||
left = left - offset.left; | ||
} | ||
el.css({ | ||
top: top, | ||
left: left | ||
}); | ||
}); | ||
}, | ||
@@ -18,0 +39,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1153884
3337