height-harmony 2.0.0 → 2.0.1
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 +3 -3
- package/dist/height-harmony-min.js +1 -1
- package/dist/height-harmony.es.js +1 -1
- package/height-harmony.js +1 -1
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Zero dependencies. ResizeObserver-powered. Automatically responsive. Drop it in
|
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](#)
|
|
10
10
|
|
|
11
|
-
**[View the interactive demo →](https://
|
|
11
|
+
**[View the interactive demo →](https://heightharmony.byronj.me/)**
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -38,7 +38,7 @@ npm install height-harmony
|
|
|
38
38
|
### CDN (UMD — no bundler needed)
|
|
39
39
|
|
|
40
40
|
```html
|
|
41
|
-
<script src="https://
|
|
41
|
+
<script src="https://cdn.jsdelivr.net/npm/height-harmony@2/dist/height-harmony-min.js"></script>
|
|
42
42
|
<script>
|
|
43
43
|
heightHarmony('.card');
|
|
44
44
|
</script>
|
|
@@ -48,7 +48,7 @@ npm install height-harmony
|
|
|
48
48
|
|
|
49
49
|
```html
|
|
50
50
|
<script type="module">
|
|
51
|
-
import heightHarmony from 'https://
|
|
51
|
+
import heightHarmony from 'https://cdn.jsdelivr.net/npm/height-harmony@2/dist/height-harmony.es.js';
|
|
52
52
|
heightHarmony('.card');
|
|
53
53
|
</script>
|
|
54
54
|
```
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @author Byron Johnson
|
|
10
10
|
* @license MIT
|
|
11
|
-
* @see https://
|
|
11
|
+
* @see https://heightharmony.byronj.me
|
|
12
12
|
*/function t(e,t){let s=null;return function(...i){null!==s&&clearTimeout(s),t>0?s=setTimeout(()=>{s=null,requestAnimationFrame(()=>e.apply(this,i))},t):requestAnimationFrame(()=>e.apply(this,i))}}class s{constructor(e,s={}){this._target=e,this._opts=Object.assign({debounce:0,minHeight:!1,breakpoint:0,watch:!0,transitions:!0},s),this._destroyed=!1,this._resizeObserver=null,this._mutationObserver=null,this._cleanupFallback=null,this._debouncedSync=t(this._sync.bind(this),this._opts.debounce),this._sync(),this._opts.watch&&this._setupObservers()}refresh(){return this._destroyed||this._sync(),this}destroy(){if(this._destroyed)return this;this._destroyed=!0,this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),this._cleanupFallback&&(this._cleanupFallback(),this._cleanupFallback=null);const e=this._opts.minHeight?"min-height":"height";return this._getElements().forEach(t=>{t.style.removeProperty(e),t.style.removeProperty("box-sizing"),this._opts.transitions&&t.style.removeProperty("transition")}),this}_getElements(){return"string"==typeof this._target?Array.from(document.querySelectorAll(this._target)):this._target instanceof NodeList||Array.isArray(this._target)?Array.from(this._target):this._target instanceof HTMLElement?[this._target]:[]}_sync(){if(this._destroyed)return;const e=this._getElements();if(0===e.length)return;if(this._opts.breakpoint>0&&window.innerWidth<this._opts.breakpoint){const t=this._opts.minHeight?"min-height":"height";return void e.forEach(e=>e.style.removeProperty(t))}const t=this._opts.minHeight?"min-height":"height";e.forEach(e=>{e.style.setProperty(t,"","important"),e.style.setProperty("box-sizing","border-box","important")});let s=0;e.forEach(e=>{const t=e.offsetHeight;t>s&&(s=t)}),0!==s&&e.forEach(e=>{this._opts.transitions&&e.style.setProperty("transition",`${t} 0.2s ease`,""),e.style.setProperty(t,`${s}px`,"important")})}_setupObservers(){if("undefined"!=typeof ResizeObserver)this._resizeObserver=new ResizeObserver(e=>{e.length>0&&this._debouncedSync()}),(()=>{this._getElements().forEach(e=>this._resizeObserver.observe(e))})();else{const e=t(this._sync.bind(this),Math.max(this._opts.debounce,150)),s=()=>setTimeout(()=>this._sync(),300);window.addEventListener("resize",e,{passive:!0}),window.addEventListener("orientationchange",s,{passive:!0}),this._cleanupFallback=()=>{window.removeEventListener("resize",e),window.removeEventListener("orientationchange",s)}}if("undefined"!=typeof MutationObserver){const e=this._getElements(),t=new Set(e.map(e=>e.parentElement).filter(Boolean));t.size>0&&(this._mutationObserver=new MutationObserver(e=>{e.some(e=>e.addedNodes.length>0||e.removedNodes.length>0)&&(this._debouncedSync(),this._resizeObserver&&this._getElements().forEach(e=>{try{this._resizeObserver.observe(e)}catch(t){}}))}),t.forEach(e=>{this._mutationObserver.observe(e,{childList:!0,subtree:!1})}))}}}function i(e,t){return new s(e,t)}i.version="2.0.0",i.autoInit=function(e={}){const t=document.querySelectorAll("[data-hh-group]");if(0===t.length)return[];const i=new Map;t.forEach(e=>{const t=e.getAttribute("data-hh-group");i.has(t)||i.set(t,[]),i.get(t).push(e)});const r=[];return i.forEach(t=>{r.push(new s(t,e))}),r},e.HeightHarmonyInstance=s,e.default=i,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/height-harmony.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "height-harmony",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A lightweight, zero-dependency JavaScript utility for equalizing element heights",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -28,8 +28,6 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
30
30
|
"build": "vite build",
|
|
31
|
-
"build:demo": "cp dist/height-harmony-min.js demo/height-harmony-min.js && vite build --config demo/vite.config.js && cp dist/height-harmony-min.js demo-dist/height-harmony-min.js",
|
|
32
|
-
"build:all": "npm run build && npm run build:demo",
|
|
33
31
|
"dev": "vite build --watch",
|
|
34
32
|
"prepublishOnly": "npm run build"
|
|
35
33
|
},
|
|
@@ -37,7 +35,7 @@
|
|
|
37
35
|
"type": "git",
|
|
38
36
|
"url": "git+https://github.com/byronjohnson/height-harmony.git"
|
|
39
37
|
},
|
|
40
|
-
"homepage": "https://
|
|
38
|
+
"homepage": "https://heightharmony.byronj.me",
|
|
41
39
|
"bugs": {
|
|
42
40
|
"url": "https://github.com/byronjohnson/height-harmony/issues"
|
|
43
41
|
},
|