liquid-gl 2.2.1 → 2.2.3

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  <a href="https://liquidgl.naughtyduk.com"><img src="https://raw.githubusercontent.com/naughtyduk/liquidGL/main/assets/liquidGL-npm-preview.gif" alt="liquidGL" width="100%" height="auto"/></a>
4
4
 
5
- ### v2.2.1
5
+ ### v2.2.3
6
6
 
7
7
  > [!NOTE]
8
8
  > `liquidGL` is free to use for both non-commercial and commercial purposes.
@@ -234,10 +234,10 @@ Passing `gsap` lets `liquidGL` drive its render loop from the GSAP ticker and ke
234
234
 
235
235
  | Option | Type | Default | Description |
236
236
  | ------------ | -------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
237
- | `target` | string | `'.liquidGL'` | **Required.** CSS selector for the element(s) to glassify. |
237
+ | `engine` | string | `'auto'` | Render backend chain: `'auto'` (WebGPU → WebGL2 → WebGL1 → CSS), `'webgpu'` (WebGPU → CSS), `'webgl2'` (WebGL2 → WebGL1 → CSS) or `'webgl'` (WebGL1 → CSS). |
238
238
  | `snapshot` | string | `'body'` | CSS selector for the element to snapshot. |
239
+ | `target` | string | `'.liquidGL'` | **Required.** CSS selector for the element(s) to glassify. |
239
240
  | `resolution` | number | `2.0` | Resolution of the background snapshot (clamped 0.1–3.0). Higher is sharper but uses more memory. |
240
- | `engine` | string | `'auto'` | Render backend chain: `'auto'` (WebGPU → WebGL2 → WebGL1 → CSS), `'webgpu'` (WebGPU → CSS), `'webgl2'` (WebGL2 → WebGL1 → CSS) or `'webgl'` (WebGL1 → CSS). |
241
241
  | `refraction` | number | `0.01` | Base refraction offset applied across the pane (0–1). |
242
242
  | `aberration` | number | `0` | Chromatic aberration strength (0–1). Scales with the refraction offset, so dispersion is strongest at the bevel. `0` disables it and skips the extra texture samples. |
243
243
  | `bevelDepth` | number | `0.08` | Additional refraction on the edge to simulate depth (0–1). |
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Author: NaughtyDuk© – https://liquidgl.naughtyduk.com
6
6
  * Licence: MIT
7
- * Version: v2.2.1
7
+ * Version: v2.2.3
8
8
  */
9
9
 
10
10
  (() => {
package/liquidGL.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Author: NaughtyDuk© – https://liquidgl.naughtyduk.com
6
6
  * Licence: MIT
7
- * Version: v2.2.1
7
+ * Version: v2.2.3
8
8
  */
9
9
 
10
10
  const liquidGL = (() => {
@@ -2958,6 +2958,7 @@ fn fs() -> @location(0) vec4<f32> {
2958
2958
  if (!this.snapshotTarget) this.snapshotTarget = document.body;
2959
2959
 
2960
2960
  this._isScrolling = false;
2961
+ this._pendingViewportResize = false;
2961
2962
  let lastScrollY = window.scrollY;
2962
2963
  let scrollTimeout;
2963
2964
  const scrollCheck = () => {
@@ -2967,6 +2968,10 @@ fn fs() -> @location(0) vec4<f32> {
2967
2968
  clearTimeout(scrollTimeout);
2968
2969
  scrollTimeout = setTimeout(() => {
2969
2970
  this._isScrolling = false;
2971
+ if (this._pendingViewportResize) {
2972
+ this._pendingViewportResize = false;
2973
+ onResize();
2974
+ }
2970
2975
  }, 200);
2971
2976
  }
2972
2977
  requestAnimationFrame(scrollCheck);
@@ -2974,7 +2979,12 @@ fn fs() -> @location(0) vec4<f32> {
2974
2979
  requestAnimationFrame(scrollCheck);
2975
2980
 
2976
2981
  const onResize = debounce(() => {
2977
- if (this._capturing || this._isScrolling) return;
2982
+ if (this._capturing) return;
2983
+ if (this._isScrolling) {
2984
+ this._pendingViewportResize = true;
2985
+ return;
2986
+ }
2987
+ this._pendingViewportResize = false;
2978
2988
 
2979
2989
  if (window.visualViewport && window.visualViewport.scale !== 1) {
2980
2990
  return;
@@ -3333,6 +3343,13 @@ fn fs() -> @location(0) vec4<f32> {
3333
3343
  const backend = this.backend;
3334
3344
  if (!backend || !this.hasTexture) return;
3335
3345
 
3346
+ const dprNow = Math.min(2, window.devicePixelRatio || 1);
3347
+ const bufW = Math.trunc(innerWidth * dprNow);
3348
+ const bufH = Math.trunc(innerHeight * dprNow);
3349
+ if (this.canvas.width !== bufW || this.canvas.height !== bufH) {
3350
+ this._resizeCanvas();
3351
+ }
3352
+
3336
3353
  this.lenses.forEach((ln) => {
3337
3354
  if (ln._isSticky && !ln._mirrorActive) ln.updateMetrics();
3338
3355
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liquid-gl",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "Liquid Glass - Powered by WebGPU/WebGL.",
5
5
  "type": "module",
6
6
  "main": "./liquidGL.js",