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 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:
@@ -1,13 +1,13 @@
1
1
  /*!
2
- handy-scroll v2.0.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;position:sticky}:host([viewport]:state(latent)){position:fixed}';
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 && (t === "owner" ? this.#a() : t === "viewport" && this.#c(), this.#w(), this.#p(), this.#u(), this.#f(), this.update());
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.1",
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.9.1",
40
- "@stylistic/eslint-plugin-js": "^2.7.2",
41
- "eslint": "^9.9.1",
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.2"
43
+ "vite": "^5.4.5"
44
44
  }
45
45
  }
@@ -31,8 +31,11 @@
31
31
  }
32
32
  }
33
33
 
34
- :host([viewport]) {
34
+ :host([viewport]:not([hidden])) {
35
35
  display: block;
36
+ }
37
+
38
+ :host([viewport]) {
36
39
  position: sticky;
37
40
  }
38
41
 
@@ -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") {