Adding events and better why sectino
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Sam Russell
|
||||
Captured Sun
|
||||
11.19.25 - Allowing for "auto" values in otherwise numeric styles, adding vmin and vmax units
|
||||
11.17.25.3 - Adding styles() and fixing dynamic function from earlier
|
||||
11.17.25.2 - Fixing onNavigate() and onAppear()
|
||||
11.17.25 - Added dynamic function to have units in style func parameters.
|
||||
@@ -218,6 +219,8 @@ HTMLElement.prototype.rerender = function() {
|
||||
|
||||
/* Styling */
|
||||
|
||||
window.vmin = "vmin"
|
||||
window.vmax = "vmax"
|
||||
window.vh = "vh"
|
||||
window.vw = "vw"
|
||||
window.px = "px"
|
||||
@@ -304,9 +307,13 @@ function extendHTMLElementWithStyleSetters() {
|
||||
switch (type) {
|
||||
case "unit-number":
|
||||
HTMLElement.prototype[prop] = function(value, unit = "px") {
|
||||
if (typeof value !== "number" || isNaN(value)) {
|
||||
if ((typeof value !== "number" || isNaN(value)) && value !== "auto") {
|
||||
throw new Error(`Invalid value for ${prop}: ${value}. Expected a number.`);
|
||||
}
|
||||
if(value === "auto") {
|
||||
this.style[prop] = value
|
||||
return this
|
||||
}
|
||||
this.style[prop] = value + unit;
|
||||
return this;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user