handy-scroll 2.0.1 → 2.0.2
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/README.md +6 -0
- package/dist/handy-scroll.mjs +10 -4
- package/package.json +5 -5
- package/src/handy-scroll.css +4 -1
- package/src/handy-scroll.mjs +7 -1
package/README.md
CHANGED
|
@@ -29,6 +29,12 @@ If you don’t use bundlers, just import the component as a module in your HTML
|
|
|
29
29
|
<script type="module" src="https://esm.run/handy-scroll"></script>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
or in your ES modules:
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import "https://esm.run/handy-scroll";
|
|
36
|
+
```
|
|
37
|
+
|
|
32
38
|
## Standard usage
|
|
33
39
|
|
|
34
40
|
Drop the custom element `<handy-scroll>` where you need in your markup and link the component to the horizontally-scrollable target using the `owner` attribute:
|
package/dist/handy-scroll.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
handy-scroll v2.0.
|
|
2
|
+
handy-scroll v2.0.2
|
|
3
3
|
https://amphiluke.github.io/handy-scroll/
|
|
4
4
|
(c) 2024 Amphiluke
|
|
5
5
|
*/
|
|
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]){display:block
|
|
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}';
|
|
7
7
|
let h = (n) => `Attribute ‘${n}’ must reference a valid container ‘id’`;
|
|
8
8
|
class r extends HTMLElement {
|
|
9
9
|
static get observedAttributes() {
|
|
10
|
-
return ["owner", "viewport"];
|
|
10
|
+
return ["owner", "viewport", "hidden"];
|
|
11
11
|
}
|
|
12
12
|
#o = null;
|
|
13
13
|
#t = null;
|
|
@@ -47,7 +47,13 @@ class r extends HTMLElement {
|
|
|
47
47
|
this.#w(), this.#p(), this.#e = this.#t = null;
|
|
48
48
|
}
|
|
49
49
|
attributeChangedCallback(t) {
|
|
50
|
-
this.#i.size
|
|
50
|
+
if (this.#i.size) {
|
|
51
|
+
if (t === "hidden") {
|
|
52
|
+
this.hasAttribute("hidden") || this.update();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
t === "owner" ? this.#a() : t === "viewport" && this.#c(), this.#w(), this.#p(), this.#u(), this.#f(), this.update();
|
|
56
|
+
}
|
|
51
57
|
}
|
|
52
58
|
#a() {
|
|
53
59
|
let t = this.getAttribute("owner");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "handy-scroll",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
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.
|
|
39
|
+
"@eslint/js": "^9.10.0",
|
|
40
|
+
"@stylistic/eslint-plugin-js": "^2.8.0",
|
|
41
|
+
"eslint": "^9.10.0",
|
|
42
42
|
"globals": "^15.9.0",
|
|
43
|
-
"vite": "^5.4.
|
|
43
|
+
"vite": "^5.4.5"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/handy-scroll.css
CHANGED
package/src/handy-scroll.mjs
CHANGED
|
@@ -4,7 +4,7 @@ let getAttributeErrorMessage = (attribute) => `Attribute ‘${attribute}’ must
|
|
|
4
4
|
|
|
5
5
|
class HandyScroll extends HTMLElement {
|
|
6
6
|
static get observedAttributes() {
|
|
7
|
-
return ["owner", "viewport"];
|
|
7
|
+
return ["owner", "viewport", "hidden"];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
#internals = null;
|
|
@@ -73,6 +73,12 @@ class HandyScroll extends HTMLElement {
|
|
|
73
73
|
if (!this.#eventHandlers.size) { // handle only dynamic changes when the element is completely connected
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
+
if (name === "hidden") {
|
|
77
|
+
if (!this.hasAttribute("hidden")) {
|
|
78
|
+
this.update();
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
76
82
|
if (name === "owner") {
|
|
77
83
|
this.#bindOwner();
|
|
78
84
|
} else if (name === "viewport") {
|