@surdeddd/bottom-sheet 0.7.0 → 0.8.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.
@@ -236,6 +236,7 @@ declare class BottomSheetEngine {
236
236
  private progressWriteSentinel;
237
237
  private isTopSheet;
238
238
  private opening;
239
+ private allowOvershoot;
239
240
  private progressPayload;
240
241
  private dragContextBuf;
241
242
  private bus;
@@ -294,7 +295,7 @@ declare class BottomSheetEngine {
294
295
  setSnapPoints(points: EngineOptions["snapPoints"], allowed?: string[]): void;
295
296
  recompute(): void;
296
297
  private contentTargets;
297
- private measureContentExtent;
298
+ private measureSheetNatural;
298
299
  private measureFitSize;
299
300
  private installFitObserver;
300
301
  destroy(): void;
@@ -236,6 +236,7 @@ declare class BottomSheetEngine {
236
236
  private progressWriteSentinel;
237
237
  private isTopSheet;
238
238
  private opening;
239
+ private allowOvershoot;
239
240
  private progressPayload;
240
241
  private dragContextBuf;
241
242
  private bus;
@@ -294,7 +295,7 @@ declare class BottomSheetEngine {
294
295
  setSnapPoints(points: EngineOptions["snapPoints"], allowed?: string[]): void;
295
296
  recompute(): void;
296
297
  private contentTargets;
297
- private measureContentExtent;
298
+ private measureSheetNatural;
298
299
  private measureFitSize;
299
300
  private installFitObserver;
300
301
  destroy(): void;
package/dist/element.cjs CHANGED
@@ -2599,6 +2599,7 @@ var init_BottomSheetEngine = __esm({
2599
2599
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2600
2600
  __publicField(this, "isTopSheet", true);
2601
2601
  __publicField(this, "opening", false);
2602
+ __publicField(this, "allowOvershoot", false);
2602
2603
  __publicField(this, "progressPayload", {
2603
2604
  value: 0,
2604
2605
  size: 0
@@ -3151,40 +3152,32 @@ var init_BottomSheetEngine = __esm({
3151
3152
  }
3152
3153
  return out;
3153
3154
  }
3154
- measureContentExtent(vertical) {
3155
+ measureSheetNatural(vertical) {
3156
+ const el = this.element;
3155
3157
  const content = this.scrollContainer;
3156
- if (!content) return 0;
3157
- const targets = this.contentTargets();
3158
- if (targets.length === 0) {
3159
- return vertical ? content.scrollHeight : content.scrollWidth;
3158
+ if (!content) {
3159
+ return vertical ? el.offsetHeight : el.offsetWidth;
3160
3160
  }
3161
- let min = Infinity;
3162
- let max = -Infinity;
3163
- for (const el of targets) {
3164
- const r = el.getBoundingClientRect();
3165
- if (vertical) {
3166
- if (r.top < min) min = r.top;
3167
- if (r.bottom > max) max = r.bottom;
3168
- } else {
3169
- if (r.left < min) min = r.left;
3170
- if (r.right > max) max = r.right;
3171
- }
3172
- }
3173
- if (!isFinite(min) || !isFinite(max) || max <= min) {
3174
- return vertical ? content.scrollHeight : content.scrollWidth;
3175
- }
3176
- let pad = 0;
3177
- if (typeof getComputedStyle !== "undefined") {
3178
- const cs = getComputedStyle(content);
3179
- pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
3180
- }
3181
- return max - min + pad;
3161
+ const axis = vertical ? "height" : "width";
3162
+ const sheetStyle = el.style;
3163
+ const cs = content.style;
3164
+ const prevSheet = sheetStyle[axis];
3165
+ const prevFlex = cs.flex;
3166
+ const prevContent = vertical ? cs.height : cs.width;
3167
+ sheetStyle[axis] = "auto";
3168
+ cs.flex = "none";
3169
+ if (vertical) cs.height = "auto";
3170
+ else cs.width = "auto";
3171
+ const natural = vertical ? el.offsetHeight : el.offsetWidth;
3172
+ sheetStyle[axis] = prevSheet;
3173
+ cs.flex = prevFlex;
3174
+ if (vertical) cs.height = prevContent;
3175
+ else cs.width = prevContent;
3176
+ return natural;
3182
3177
  }
3183
3178
  measureFitSize() {
3184
3179
  const vertical = layoutAxis(this.mode) === "height";
3185
- const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
3186
- const content = this.scrollContainer;
3187
- const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
3180
+ const natural = this.measureSheetNatural(vertical);
3188
3181
  const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
3189
3182
  if (typeof window === "undefined") return capped;
3190
3183
  const viewport = vertical ? window.innerHeight : window.innerWidth;
@@ -3270,6 +3263,10 @@ var init_BottomSheetEngine = __esm({
3270
3263
  this.backdrop.style.opacity = "";
3271
3264
  this.backdrop.style.pointerEvents = "";
3272
3265
  }
3266
+ if (this.anchorHost) {
3267
+ this.anchorHost.style.removeProperty("--bs-size");
3268
+ this.anchorHost.style.removeProperty("--bs-progress");
3269
+ }
3273
3270
  if (this.screenComponent) {
3274
3271
  this.screenComponent.style.opacity = "";
3275
3272
  this.screenComponent.style.display = "";
@@ -3281,6 +3278,7 @@ var init_BottomSheetEngine = __esm({
3281
3278
  this.bus.emit(event, payload);
3282
3279
  }
3283
3280
  newCycle() {
3281
+ this.allowOvershoot = false;
3284
3282
  this.currentAbort.abort();
3285
3283
  this.currentAbort = new AbortController();
3286
3284
  return this.currentAbort.signal;
@@ -3346,6 +3344,7 @@ var init_BottomSheetEngine = __esm({
3346
3344
  seen.add(p.id);
3347
3345
  }
3348
3346
  this.snaps.setRaw(this.snapPointsRaw);
3347
+ this.clampToMaxHeight();
3349
3348
  this.scrim.invalidateOpacityCache();
3350
3349
  }
3351
3350
  getAllowedRange() {
@@ -3552,9 +3551,13 @@ var init_BottomSheetEngine = __esm({
3552
3551
  this.opening = true;
3553
3552
  sheetStack.promote(this.id);
3554
3553
  }
3555
- void this.animation.animateTo(target.size, velocity).then(() => {
3556
- this.opening = false;
3554
+ const settleCap = this.snaps.getMaxAxisSize();
3555
+ const settleSize = settleCap > 0 ? Math.min(target.size, settleCap) : target.size;
3556
+ this.allowOvershoot = true;
3557
+ void this.animation.animateTo(settleSize, velocity).then(() => {
3557
3558
  if (signal.aborted) return;
3559
+ this.allowOvershoot = false;
3560
+ this.opening = false;
3558
3561
  this.scrollCache.restore(target.id, previousSize, target.size);
3559
3562
  this.updateAriaSlider();
3560
3563
  this.emit("snap", {
@@ -3586,7 +3589,7 @@ var init_BottomSheetEngine = __esm({
3586
3589
  }
3587
3590
  applySize(size) {
3588
3591
  const cap = this.snaps.getMaxAxisSize();
3589
- const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3592
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging && !this.allowOvershoot ? cap : size;
3590
3593
  this.size = clamped;
3591
3594
  const offset = cap - clamped;
3592
3595
  const style = this.element.style;
@@ -1,4 +1,4 @@
1
- import { B as BottomSheetEngine, C as CloseReason, A as AnchorOptions, S as ScrimStagesOptions, E as EngineState } from './BottomSheetEngine-CqiCz64W.cjs';
1
+ import { B as BottomSheetEngine, C as CloseReason, A as AnchorOptions, S as ScrimStagesOptions, E as EngineState } from './BottomSheetEngine-BD1mSExI.cjs';
2
2
  import './transform-jVfAikE9.cjs';
3
3
 
4
4
  declare const BaseHTMLElement: typeof HTMLElement;
package/dist/element.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as BottomSheetEngine, C as CloseReason, A as AnchorOptions, S as ScrimStagesOptions, E as EngineState } from './BottomSheetEngine-BHjKFtnM.js';
1
+ import { B as BottomSheetEngine, C as CloseReason, A as AnchorOptions, S as ScrimStagesOptions, E as EngineState } from './BottomSheetEngine-BDGRWa2i.js';
2
2
  import './transform-jVfAikE9.js';
3
3
 
4
4
  declare const BaseHTMLElement: typeof HTMLElement;