Added document methods

This commit is contained in:
Ray 2024-09-18 23:38:17 +01:00
parent 1d9c6bd146
commit c4434e1b2b
2 changed files with 49 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "LiteRyzJS",
"version": "0.1.0.357",
"version": "0.1.0.397",
"devDependencies": {
"css-loader": "^7.1.2",
"sass": "^1.77.8",

View File

@ -6,4 +6,51 @@ Document.ready = async function(fn) {
fn();
});
})();
}
}
Document.getWidth = function(el) {
if (el == null) {
return 0;
}
if (typeof(el) == "undefined") {
return 0;
}
return (el.offsetWidth || el.innerWidth || el.clientWidth);
}
Document.getHeight = function(el) {
if (el == null) {
return 0;
}
if (typeof(el) == "undefined") {
return 0;
}
return (el.offsetHeight || el.innerHeight || el.clientHeight);
}
Document.appendHtml = function(el, html) {
const newEl = document.createElement(html);
el.appendChild(newEl);
}
Document.addClass = function(el, className) {
if (el.classList.contains(className)) {
return;
}
el.classList.add(className);
}
Document.removeClass = function(el, className) {
if (!el.classList.contains(className)) {
return;
}
el.classList.remove(className);
}