@surdeddd/bottom-sheet 0.22.1 → 0.23.0

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/dist/svelte.js CHANGED
@@ -1489,13 +1489,17 @@ var AnimationRunner = class {
1489
1489
  });
1490
1490
  let stopped = false;
1491
1491
  let auxRaf = 0;
1492
- const start = performance.now();
1493
1492
  const lastIdx = samples.values.length - 1;
1494
1493
  const auxTick = () => {
1495
1494
  if (stopped) return;
1496
- const elapsed = performance.now() - start;
1497
- const idx = Math.min(Math.floor(elapsed / samples.stepMs), lastIdx);
1498
- applyAux(samples.values[idx]);
1495
+ const at = Math.min(
1496
+ (Number(anim.currentTime) || 0) / samples.stepMs,
1497
+ lastIdx
1498
+ );
1499
+ const idx = Math.floor(at);
1500
+ const from = samples.values[idx];
1501
+ const to = samples.values[Math.min(idx + 1, lastIdx)];
1502
+ applyAux(from + (to - from) * (at - idx));
1499
1503
  auxRaf = requestAnimationFrame(auxTick);
1500
1504
  };
1501
1505
  auxRaf = requestAnimationFrame(auxTick);
@@ -2707,7 +2711,11 @@ var BottomSheetCore = class {
2707
2711
  getSize: () => this.size,
2708
2712
  isDragging: () => this.isDraggingAny(),
2709
2713
  applyAux: (size) => this.applySize(size, true),
2710
- getTransformFor: (size) => this.transformTemplate(this.snaps.getMaxAxisSize() - size)
2714
+ getTransformFor: (size) => {
2715
+ const cap = this.snaps.getMaxAxisSize();
2716
+ const shown = cap > 0 && !this.allowOvershoot ? Math.min(size, cap) : size;
2717
+ return this.transformTemplate(cap - shown);
2718
+ }
2711
2719
  },
2712
2720
  resolved.animation
2713
2721
  );
@@ -4239,6 +4247,9 @@ function visualViewportFeature() {
4239
4247
 
4240
4248
  // src/core/features/content-fit.ts
4241
4249
  var INSET_VAR = "--bs-content-inset";
4250
+ var SIZE_VAR = "--bs-size";
4251
+ var CAP_VAR = "--bs-max-size";
4252
+ var LIFT_VAR = "--bs-footer-lift-max";
4242
4253
  var FIT_ATTR = "data-bs-fit-content";
4243
4254
  function contentFitFeature() {
4244
4255
  return {
@@ -4252,6 +4263,7 @@ function contentFitFeature() {
4252
4263
  let inset = 0;
4253
4264
  let unpaddedMax = -1;
4254
4265
  let top = 0;
4266
+ const put = (name, px) => sheet.style.setProperty(name, `${px}px`);
4255
4267
  const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4256
4268
  const follow = (size) => {
4257
4269
  if (unpaddedMax < 0) {
@@ -4270,7 +4282,10 @@ function contentFitFeature() {
4270
4282
  unpaddedMax = -1;
4271
4283
  follow(size);
4272
4284
  inset = hiddenAt(size);
4273
- sheet.style.setProperty(INSET_VAR, `${inset}px`);
4285
+ put(LIFT_VAR, scroller.offsetHeight);
4286
+ put(INSET_VAR, inset);
4287
+ put(SIZE_VAR, size);
4288
+ put(CAP_VAR, ctx.getMaxAxisSize());
4274
4289
  unpaddedMax = -1;
4275
4290
  };
4276
4291
  const moving = () => ctx.isAnimating() || ctx.isDragging();
@@ -4293,7 +4308,9 @@ function contentFitFeature() {
4293
4308
  observer?.disconnect();
4294
4309
  window.removeEventListener("orientationchange", whenIdle);
4295
4310
  sheet.removeAttribute(FIT_ATTR);
4296
- sheet.style.removeProperty(INSET_VAR);
4311
+ for (const name of [INSET_VAR, CAP_VAR, LIFT_VAR]) {
4312
+ sheet.style.removeProperty(name);
4313
+ }
4297
4314
  };
4298
4315
  }
4299
4316
  };
package/dist/vue.cjs CHANGED
@@ -1489,13 +1489,17 @@ var AnimationRunner = class {
1489
1489
  });
1490
1490
  let stopped = false;
1491
1491
  let auxRaf = 0;
1492
- const start = performance.now();
1493
1492
  const lastIdx = samples.values.length - 1;
1494
1493
  const auxTick = () => {
1495
1494
  if (stopped) return;
1496
- const elapsed = performance.now() - start;
1497
- const idx = Math.min(Math.floor(elapsed / samples.stepMs), lastIdx);
1498
- applyAux(samples.values[idx]);
1495
+ const at = Math.min(
1496
+ (Number(anim.currentTime) || 0) / samples.stepMs,
1497
+ lastIdx
1498
+ );
1499
+ const idx = Math.floor(at);
1500
+ const from = samples.values[idx];
1501
+ const to = samples.values[Math.min(idx + 1, lastIdx)];
1502
+ applyAux(from + (to - from) * (at - idx));
1499
1503
  auxRaf = requestAnimationFrame(auxTick);
1500
1504
  };
1501
1505
  auxRaf = requestAnimationFrame(auxTick);
@@ -2707,7 +2711,11 @@ var BottomSheetCore = class {
2707
2711
  getSize: () => this.size,
2708
2712
  isDragging: () => this.isDraggingAny(),
2709
2713
  applyAux: (size) => this.applySize(size, true),
2710
- getTransformFor: (size) => this.transformTemplate(this.snaps.getMaxAxisSize() - size)
2714
+ getTransformFor: (size) => {
2715
+ const cap = this.snaps.getMaxAxisSize();
2716
+ const shown = cap > 0 && !this.allowOvershoot ? Math.min(size, cap) : size;
2717
+ return this.transformTemplate(cap - shown);
2718
+ }
2711
2719
  },
2712
2720
  resolved.animation
2713
2721
  );
@@ -4239,6 +4247,9 @@ function visualViewportFeature() {
4239
4247
 
4240
4248
  // src/core/features/content-fit.ts
4241
4249
  var INSET_VAR = "--bs-content-inset";
4250
+ var SIZE_VAR = "--bs-size";
4251
+ var CAP_VAR = "--bs-max-size";
4252
+ var LIFT_VAR = "--bs-footer-lift-max";
4242
4253
  var FIT_ATTR = "data-bs-fit-content";
4243
4254
  function contentFitFeature() {
4244
4255
  return {
@@ -4252,6 +4263,7 @@ function contentFitFeature() {
4252
4263
  let inset = 0;
4253
4264
  let unpaddedMax = -1;
4254
4265
  let top = 0;
4266
+ const put = (name, px) => sheet.style.setProperty(name, `${px}px`);
4255
4267
  const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4256
4268
  const follow = (size) => {
4257
4269
  if (unpaddedMax < 0) {
@@ -4270,7 +4282,10 @@ function contentFitFeature() {
4270
4282
  unpaddedMax = -1;
4271
4283
  follow(size);
4272
4284
  inset = hiddenAt(size);
4273
- sheet.style.setProperty(INSET_VAR, `${inset}px`);
4285
+ put(LIFT_VAR, scroller.offsetHeight);
4286
+ put(INSET_VAR, inset);
4287
+ put(SIZE_VAR, size);
4288
+ put(CAP_VAR, ctx.getMaxAxisSize());
4274
4289
  unpaddedMax = -1;
4275
4290
  };
4276
4291
  const moving = () => ctx.isAnimating() || ctx.isDragging();
@@ -4293,7 +4308,9 @@ function contentFitFeature() {
4293
4308
  observer?.disconnect();
4294
4309
  window.removeEventListener("orientationchange", whenIdle);
4295
4310
  sheet.removeAttribute(FIT_ATTR);
4296
- sheet.style.removeProperty(INSET_VAR);
4311
+ for (const name of [INSET_VAR, CAP_VAR, LIFT_VAR]) {
4312
+ sheet.style.removeProperty(name);
4313
+ }
4297
4314
  };
4298
4315
  }
4299
4316
  };
package/dist/vue.js CHANGED
@@ -1487,13 +1487,17 @@ var AnimationRunner = class {
1487
1487
  });
1488
1488
  let stopped = false;
1489
1489
  let auxRaf = 0;
1490
- const start = performance.now();
1491
1490
  const lastIdx = samples.values.length - 1;
1492
1491
  const auxTick = () => {
1493
1492
  if (stopped) return;
1494
- const elapsed = performance.now() - start;
1495
- const idx = Math.min(Math.floor(elapsed / samples.stepMs), lastIdx);
1496
- applyAux(samples.values[idx]);
1493
+ const at = Math.min(
1494
+ (Number(anim.currentTime) || 0) / samples.stepMs,
1495
+ lastIdx
1496
+ );
1497
+ const idx = Math.floor(at);
1498
+ const from = samples.values[idx];
1499
+ const to = samples.values[Math.min(idx + 1, lastIdx)];
1500
+ applyAux(from + (to - from) * (at - idx));
1497
1501
  auxRaf = requestAnimationFrame(auxTick);
1498
1502
  };
1499
1503
  auxRaf = requestAnimationFrame(auxTick);
@@ -2705,7 +2709,11 @@ var BottomSheetCore = class {
2705
2709
  getSize: () => this.size,
2706
2710
  isDragging: () => this.isDraggingAny(),
2707
2711
  applyAux: (size) => this.applySize(size, true),
2708
- getTransformFor: (size) => this.transformTemplate(this.snaps.getMaxAxisSize() - size)
2712
+ getTransformFor: (size) => {
2713
+ const cap = this.snaps.getMaxAxisSize();
2714
+ const shown = cap > 0 && !this.allowOvershoot ? Math.min(size, cap) : size;
2715
+ return this.transformTemplate(cap - shown);
2716
+ }
2709
2717
  },
2710
2718
  resolved.animation
2711
2719
  );
@@ -4237,6 +4245,9 @@ function visualViewportFeature() {
4237
4245
 
4238
4246
  // src/core/features/content-fit.ts
4239
4247
  var INSET_VAR = "--bs-content-inset";
4248
+ var SIZE_VAR = "--bs-size";
4249
+ var CAP_VAR = "--bs-max-size";
4250
+ var LIFT_VAR = "--bs-footer-lift-max";
4240
4251
  var FIT_ATTR = "data-bs-fit-content";
4241
4252
  function contentFitFeature() {
4242
4253
  return {
@@ -4250,6 +4261,7 @@ function contentFitFeature() {
4250
4261
  let inset = 0;
4251
4262
  let unpaddedMax = -1;
4252
4263
  let top = 0;
4264
+ const put = (name, px) => sheet.style.setProperty(name, `${px}px`);
4253
4265
  const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4254
4266
  const follow = (size) => {
4255
4267
  if (unpaddedMax < 0) {
@@ -4268,7 +4280,10 @@ function contentFitFeature() {
4268
4280
  unpaddedMax = -1;
4269
4281
  follow(size);
4270
4282
  inset = hiddenAt(size);
4271
- sheet.style.setProperty(INSET_VAR, `${inset}px`);
4283
+ put(LIFT_VAR, scroller.offsetHeight);
4284
+ put(INSET_VAR, inset);
4285
+ put(SIZE_VAR, size);
4286
+ put(CAP_VAR, ctx.getMaxAxisSize());
4272
4287
  unpaddedMax = -1;
4273
4288
  };
4274
4289
  const moving = () => ctx.isAnimating() || ctx.isDragging();
@@ -4291,7 +4306,9 @@ function contentFitFeature() {
4291
4306
  observer?.disconnect();
4292
4307
  window.removeEventListener("orientationchange", whenIdle);
4293
4308
  sheet.removeAttribute(FIT_ATTR);
4294
- sheet.style.removeProperty(INSET_VAR);
4309
+ for (const name of [INSET_VAR, CAP_VAR, LIFT_VAR]) {
4310
+ sheet.style.removeProperty(name);
4311
+ }
4295
4312
  };
4296
4313
  }
4297
4314
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surdeddd/bottom-sheet",
3
- "version": "0.22.1",
3
+ "version": "0.23.0",
4
4
  "description": "Universal, headless bottom sheet — framework-agnostic core with React, Vue 3, Svelte, Solid, Qwik, Preact, Lit and Custom Element adapters. Pointer Events, snap points, momentum, a11y, SSR-safe.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -240,37 +240,37 @@
240
240
  {
241
241
  "name": "core (engine + types)",
242
242
  "path": "dist/index.js",
243
- "limit": "22.1 KB",
243
+ "limit": "22.22 KB",
244
244
  "gzip": true
245
245
  },
246
246
  {
247
247
  "name": "react adapter",
248
248
  "path": "dist/react.js",
249
- "limit": "29.57 KB",
249
+ "limit": "29.71 KB",
250
250
  "gzip": true
251
251
  },
252
252
  {
253
253
  "name": "vue adapter",
254
254
  "path": "dist/vue.js",
255
- "limit": "25.32 KB",
255
+ "limit": "25.43 KB",
256
256
  "gzip": true
257
257
  },
258
258
  {
259
259
  "name": "svelte adapter",
260
260
  "path": "dist/svelte.js",
261
- "limit": "24.96 KB",
261
+ "limit": "25.11 KB",
262
262
  "gzip": true
263
263
  },
264
264
  {
265
265
  "name": "solid adapter",
266
266
  "path": "dist/solid.js",
267
- "limit": "23.61 KB",
267
+ "limit": "23.74 KB",
268
268
  "gzip": true
269
269
  },
270
270
  {
271
271
  "name": "qwik adapter",
272
272
  "path": "dist/qwik.js",
273
- "limit": "23.66 KB",
273
+ "limit": "23.78 KB",
274
274
  "gzip": true
275
275
  },
276
276
  {
@@ -285,13 +285,13 @@
285
285
  {
286
286
  "name": "web component (self-contained)",
287
287
  "path": "dist/element.js",
288
- "limit": "28.8 KB",
288
+ "limit": "29 KB",
289
289
  "gzip": true
290
290
  },
291
291
  {
292
292
  "name": "web component (IIFE / CDN)",
293
293
  "path": "dist/element.iife.global.js",
294
- "limit": "28.38 KB",
294
+ "limit": "28.57 KB",
295
295
  "gzip": true
296
296
  },
297
297
  {
@@ -309,13 +309,13 @@
309
309
  {
310
310
  "name": "slim core (subpath, no optional features)",
311
311
  "path": "dist/core.js",
312
- "limit": "19.85 KB",
312
+ "limit": "19.89 KB",
313
313
  "gzip": true
314
314
  },
315
315
  {
316
316
  "name": "features (subpath)",
317
317
  "path": "dist/features.js",
318
- "limit": "2.6 KB",
318
+ "limit": "2.68 KB",
319
319
  "gzip": true
320
320
  },
321
321
  {