handy-scroll 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/handy-scroll.mjs +13 -12
- package/package.json +6 -6
- package/src/handy-scroll.mjs +4 -3
package/dist/handy-scroll.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
handy-scroll v2.0.
|
|
2
|
+
handy-scroll v2.0.4
|
|
3
3
|
https://amphiluke.github.io/handy-scroll/
|
|
4
|
-
(c)
|
|
4
|
+
(c) 2025 Amphiluke
|
|
5
5
|
*/
|
|
6
|
-
const
|
|
6
|
+
const o = ':host{bottom:0;min-height:17px;overflow:auto;position:fixed}.strut{height:1px;overflow:hidden;pointer-events:none;&:before{content:" "}}:host,.strut{font-size:1px;line-height:0;margin:0;padding:0}:host(:state(latent)){bottom:110vh;.strut:before{content:" "}}:host([viewport]:not([hidden])){display:block}:host([viewport]){position:sticky}:host([viewport]:state(latent)){position:fixed}', h = new CSSStyleSheet();
|
|
7
|
+
h.replaceSync(o);
|
|
7
8
|
let n = (s) => `Attribute ‘${s}’ must reference a valid container ‘id’`;
|
|
8
|
-
class
|
|
9
|
+
class r extends HTMLElement {
|
|
9
10
|
static get observedAttributes() {
|
|
10
11
|
return ["owner", "viewport", "hidden"];
|
|
11
12
|
}
|
|
@@ -37,8 +38,8 @@ class o extends HTMLElement {
|
|
|
37
38
|
}
|
|
38
39
|
constructor() {
|
|
39
40
|
super();
|
|
40
|
-
let t = this.attachShadow({ mode: "open" })
|
|
41
|
-
|
|
41
|
+
let t = this.attachShadow({ mode: "open" });
|
|
42
|
+
t.adoptedStyleSheets = [h], this.#s = document.createElement("div"), this.#s.classList.add("strut"), t.appendChild(this.#s), this.#o = this.attachInternals();
|
|
42
43
|
}
|
|
43
44
|
connectedCallback() {
|
|
44
45
|
this.#a(), this.#c(), this.#u(), this.#p(), this.update();
|
|
@@ -104,17 +105,17 @@ class o extends HTMLElement {
|
|
|
104
105
|
#v() {
|
|
105
106
|
let t = this.scrollWidth <= this.offsetWidth;
|
|
106
107
|
if (!t) {
|
|
107
|
-
let
|
|
108
|
-
t =
|
|
108
|
+
let i = this.#e.getBoundingClientRect(), e = this.#t === window ? window.innerHeight || document.documentElement.clientHeight : this.#t.getBoundingClientRect().bottom;
|
|
109
|
+
t = i.bottom <= e || i.top > e;
|
|
109
110
|
}
|
|
110
111
|
this.#h !== t && (this.#h = t);
|
|
111
112
|
}
|
|
112
113
|
update() {
|
|
113
|
-
let { clientWidth: t, scrollWidth:
|
|
114
|
-
|
|
114
|
+
let { clientWidth: t, scrollWidth: i } = this.#e, { style: e } = this;
|
|
115
|
+
e.width = `${t}px`, this.#t === window && (e.left = `${this.#e.getBoundingClientRect().left}px`), this.#s.style.width = `${i}px`, i > t && (e.height = `${this.offsetHeight - this.clientHeight + 1}px`), this.#d(), this.#v();
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
|
-
customElements.define("handy-scroll",
|
|
118
|
+
customElements.define("handy-scroll", r);
|
|
118
119
|
export {
|
|
119
|
-
|
|
120
|
+
r as default
|
|
120
121
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "handy-scroll",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Handy dependency-free floating scrollbar web component",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://amphiluke.github.io/handy-scroll/",
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@eslint/js": "^9.
|
|
40
|
-
"@stylistic/eslint-plugin-js": "^2.
|
|
41
|
-
"eslint": "^9.
|
|
42
|
-
"globals": "^
|
|
43
|
-
"vite": "^
|
|
39
|
+
"@eslint/js": "^9.24.0",
|
|
40
|
+
"@stylistic/eslint-plugin-js": "^4.2.0",
|
|
41
|
+
"eslint": "^9.24.0",
|
|
42
|
+
"globals": "^16.0.0",
|
|
43
|
+
"vite": "^6.2.5"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/handy-scroll.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import css from "./handy-scroll.css?inline";
|
|
2
2
|
|
|
3
|
+
const stylesheet = new CSSStyleSheet();
|
|
4
|
+
stylesheet.replaceSync(css);
|
|
5
|
+
|
|
3
6
|
let getAttributeErrorMessage = (attribute) => `Attribute ‘${attribute}’ must reference a valid container ‘id’`;
|
|
4
7
|
|
|
5
8
|
class HandyScroll extends HTMLElement {
|
|
@@ -44,9 +47,7 @@ class HandyScroll extends HTMLElement {
|
|
|
44
47
|
super();
|
|
45
48
|
let shadowRoot = this.attachShadow({mode: "open"});
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
style.textContent = css;
|
|
49
|
-
shadowRoot.appendChild(style);
|
|
50
|
+
shadowRoot.adoptedStyleSheets = [stylesheet];
|
|
50
51
|
|
|
51
52
|
this.#strut = document.createElement("div");
|
|
52
53
|
this.#strut.classList.add("strut");
|