liquid-gl 2.2.3 → 2.2.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/README.md CHANGED
@@ -2,12 +2,12 @@
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.3
5
+ ### v2.2.4
6
6
 
7
- > [!NOTE]
7
+ > **NOTE**
8
8
  > `liquidGL` is free to use for both non-commercial and commercial purposes.
9
9
 
10
- > [!WARNING]
10
+ > **WARNING**
11
11
  > **v2.0.1 changed snapshot capture.** `liquidGL` now snapshots the page with its own built-in rasteriser, so `html2canvas` is no longer a dependency. Nothing needs to change in your code.
12
12
  >
13
13
  > | Rasteriser | Median | Min | Max | Worst single stall |
@@ -29,6 +29,8 @@
29
29
 
30
30
  **Features**
31
31
 
32
+ - **2.2.4 - HD Glass on Mobile** — Snapshot capture is no longer hard capped by the device's screen resolution, and is instead capped by the GPU texture limit set by the browser, allowing for higher quality glass on mobile devices.
33
+
32
34
  - **2.2.0 - WebGPU rendering** — `liquidGL` now renders with WebGPU where available, with an automatic fallback chain of WebGPU → WebGL2 → WebGL1 → CSS `backdrop-filter`. Nothing to configure, the chain is fully automatic. Choose where the chain starts with the new `engine` option (`'auto'`, `'webgpu'`, `'webgl2'`, `'webgl'`), or test quickly via the URL parameter `?liquidGL-engine=webgl2`.
33
35
 
34
36
  - **2.2.0 - Helper GUI is now a separate file** — the dev GUI no longer ships in the main bundle. Import `liquid-gl/liquidGL-helper.js` in development to keep using `helper: true`. If the module is missing you'll get a console error and everything else works as normal.
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Author: NaughtyDuk© – https://liquidgl.naughtyduk.com
6
6
  * Licence: MIT
7
- * Version: v2.2.3
7
+ * Version: v2.2.4
8
8
  */
9
9
 
10
10
  (() => {
@@ -127,8 +127,8 @@
127
127
 
128
128
  @media (max-width: 768px) {
129
129
  .lil-gui.root.liquidgl-helper {
130
- top: 1rem !important;
131
- right: 1rem !important;
130
+ top: 0.5rem !important;
131
+ right: 0.5rem !important;
132
132
  }
133
133
  }
134
134
  `;
@@ -149,6 +149,7 @@
149
149
  });
150
150
  gui.domElement.classList.add("liquidgl-helper");
151
151
  gui.$title.style.cursor = "default";
152
+ gui.close();
152
153
 
153
154
  const topOffset = 1 + instanceIndex * 3;
154
155
  gui.domElement.style.top = `${topOffset}rem`;
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.3
7
+ * Version: v2.2.4
8
8
  */
9
9
 
10
10
  const liquidGL = (() => {
@@ -2822,7 +2822,7 @@ fn fs() -> @location(0) vec4<f32> {
2822
2822
 
2823
2823
  drawLens(lens, p) {
2824
2824
  const cx = Math.max(0, p.x);
2825
- const cy = Math.max(0, p.y);
2825
+ const cy = Math.max(0, this.canvas.height - p.y - p.h);
2826
2826
  const cw = Math.min(this.canvas.width - cx, p.w);
2827
2827
  const ch = Math.min(this.canvas.height - cy, p.h);
2828
2828
  if (cw <= 0 || ch <= 0) return;
@@ -2914,7 +2914,10 @@ fn fs() -> @location(0) vec4<f32> {
2914
2914
  pass.setVertexBuffer(0, this._vb);
2915
2915
  rects.forEach(({ x, y, w, h }) => {
2916
2916
  const cx = Math.max(0, Math.min(this.canvas.width, x));
2917
- const cy = Math.max(0, Math.min(this.canvas.height, y));
2917
+ const cy = Math.max(
2918
+ 0,
2919
+ Math.min(this.canvas.height, this.canvas.height - y - h),
2920
+ );
2918
2921
  const cw = Math.max(0, Math.min(this.canvas.width - cx, w));
2919
2922
  const ch = Math.max(0, Math.min(this.canvas.height - cy, h));
2920
2923
  if (cw > 0 && ch > 0) {
@@ -3162,8 +3165,6 @@ fn fs() -> @location(0) vec4<f32> {
3162
3165
  const fullW = this.snapshotTarget.scrollWidth;
3163
3166
  const fullH = this.snapshotTarget.scrollHeight;
3164
3167
  const maxTex = (this.backend && this.backend.maxTextureSize) || 8192;
3165
- const MAX_MOBILE_DIM = 4096;
3166
- const isMobileSafari = /iPad|iPhone|iPod/.test(navigator.userAgent);
3167
3168
 
3168
3169
  let scale = Math.min(
3169
3170
  this._snapshotResolution,
@@ -3171,12 +3172,7 @@ fn fs() -> @location(0) vec4<f32> {
3171
3172
  maxTex / fullH,
3172
3173
  );
3173
3174
 
3174
- if (isMobileSafari) {
3175
- const over = (Math.max(fullW, fullH) * scale) / MAX_MOBILE_DIM;
3176
- if (over > 1) scale = scale / over;
3177
- }
3178
-
3179
- const maxArea = isMobileSafari ? 4096 * 4096 : 16384 * 16384;
3175
+ const maxArea = maxTex * maxTex;
3180
3176
  if (fullW * fullH * scale * scale > maxArea) {
3181
3177
  scale = Math.sqrt(maxArea / (fullW * fullH));
3182
3178
  console.warn(
@@ -4252,16 +4248,24 @@ fn fs() -> @location(0) vec4<f32> {
4252
4248
  ? this._baseRect
4253
4249
  : this.el.getBoundingClientRect();
4254
4250
 
4251
+ const vv = window.visualViewport;
4252
+ const vpX = vv && Math.abs(vv.scale - 1) < 0.01 ? vv.offsetLeft : 0;
4253
+ const vpY = vv && Math.abs(vv.scale - 1) < 0.01 ? vv.offsetTop : 0;
4254
+
4255
4255
  const prev = this.rectPx;
4256
4256
  if (
4257
4257
  prev &&
4258
4258
  rect.left === prev.left &&
4259
4259
  rect.top === prev.top &&
4260
4260
  rect.width === prev.width &&
4261
- rect.height === prev.height
4261
+ rect.height === prev.height &&
4262
+ vpX === this._vpOffsetX &&
4263
+ vpY === this._vpOffsetY
4262
4264
  ) {
4263
4265
  return;
4264
4266
  }
4267
+ this._vpOffsetX = vpX;
4268
+ this._vpOffsetY = vpY;
4265
4269
 
4266
4270
  this.rectPx = {
4267
4271
  left: rect.left,
@@ -4379,8 +4383,11 @@ fn fs() -> @location(0) vec4<f32> {
4379
4383
  this._mirrorActive && this._baseRect
4380
4384
  ? this._baseRect
4381
4385
  : this.el.getBoundingClientRect();
4382
- this._shadowEl.style.left = `${r.left}px`;
4383
- this._shadowEl.style.top = `${r.top}px`;
4386
+ const vv = window.visualViewport;
4387
+ const ox = vv && Math.abs(vv.scale - 1) < 0.01 ? vv.offsetLeft : 0;
4388
+ const oy = vv && Math.abs(vv.scale - 1) < 0.01 ? vv.offsetTop : 0;
4389
+ this._shadowEl.style.left = `${r.left + ox}px`;
4390
+ this._shadowEl.style.top = `${r.top + oy}px`;
4384
4391
  this._shadowEl.style.width = `${r.width}px`;
4385
4392
  this._shadowEl.style.height = `${r.height}px`;
4386
4393
  this._shadowEl.style.borderRadius = `${this.radiusCss}px`;
@@ -4397,7 +4404,7 @@ fn fs() -> @location(0) vec4<f32> {
4397
4404
  zIndex: effectiveZ(this.el) - 2,
4398
4405
  boxShadow: SHADOW_VAL,
4399
4406
  willChange: "transform, width, height",
4400
- opacity: this.revealTypeIndex === 1 ? 0 : 1,
4407
+ opacity: this._revealProgress ?? 1,
4401
4408
  });
4402
4409
  document.body.appendChild(this._shadowEl);
4403
4410
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liquid-gl",
3
- "version": "2.2.3",
3
+ "version": "v2.2.4",
4
4
  "description": "Liquid Glass - Powered by WebGPU/WebGL.",
5
5
  "type": "module",
6
6
  "main": "./liquidGL.js",