@pacem/pacem-core 2.0.0-goldbach → 2.0.0-hadamard

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.
Files changed (40) hide show
  1. package/dist/browser/pacem-core.js +308 -89
  2. package/dist/browser/pacem-core.js.map +1 -1
  3. package/dist/browser/pacem-core.min.js +2 -2
  4. package/dist/bundle/pacem-core.min.mjs +5 -5
  5. package/dist/bundle/pacem-core.mjs +193 -67
  6. package/dist/bundle/pacem-core.mjs.map +3 -3
  7. package/dist/docs/pacem-core.json +54 -24
  8. package/dist/esm/adapter.js +1 -1
  9. package/dist/esm/binding-parser.js +3 -3
  10. package/dist/esm/command.js +1 -1
  11. package/dist/esm/comparers.js +1 -1
  12. package/dist/esm/converters.js +1 -1
  13. package/dist/esm/decorators-next.js +1 -1
  14. package/dist/esm/decorators.js +1 -1
  15. package/dist/esm/defaults.js +1 -1
  16. package/dist/esm/events.js +1 -1
  17. package/dist/esm/eventtarget.js +1 -1
  18. package/dist/esm/expression.js +1 -1
  19. package/dist/esm/index-animations.js +1 -1
  20. package/dist/esm/index-behaviors.js +1 -1
  21. package/dist/esm/index-components.js +1 -1
  22. package/dist/esm/index-iife.js +1 -1
  23. package/dist/esm/index-logging.js +1 -1
  24. package/dist/esm/index-net.js +1 -1
  25. package/dist/esm/index-root.js +1 -1
  26. package/dist/esm/index-ui.js +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/logger.js +1 -1
  29. package/dist/esm/prefix.js +1 -1
  30. package/dist/esm/promise.js +1 -1
  31. package/dist/esm/regex.js +1 -1
  32. package/dist/esm/storage.js +1 -1
  33. package/dist/esm/template.js +1 -1
  34. package/dist/esm/transforms.js +1 -1
  35. package/dist/esm/types.js +1 -1
  36. package/dist/esm/utils-customelement.js +1 -1
  37. package/dist/esm/utils-customevent.js +1 -1
  38. package/dist/esm/utils.js +2 -2
  39. package/package.json +1 -1
  40. package/typings/index.d.ts +114 -20
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-core v2.0.0-goldbach (https://js.pacem.it)
2
+ * @pacem/pacem-core v2.0.0-hadamard (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -362,7 +362,7 @@ var Utils = class _Utils {
362
362
  },
363
363
  /** Sets a CSS custom property's value on the document root (`:root`/`html`). */
364
364
  setVariable(name, value2) {
365
- getComputedStyle(document.documentElement).setProperty(name, value2);
365
+ document.documentElement.style.setProperty(name, value2);
366
366
  },
367
367
  /**
368
368
  * Naive O(n^2) implementation for an actual css class presence (definition) in the current DOM.
@@ -1440,12 +1440,12 @@ var BindingParser = class _BindingParser {
1440
1440
  * Parses a binding expression against a scope.
1441
1441
  * @param expression The bare expression text (no `{{ }}` delimiters, no `, twoway`/`, once` modifier).
1442
1442
  * @param scope What the references resolve to.
1443
- * @throws When the expression is unsafe (see {@link analyze}).
1443
+ * @throws An `Error` when the expression is unsafe (see {@link analyze}).
1444
1444
  */
1445
1445
  static parse(expression, scope) {
1446
1446
  const analysis = _BindingParser.analyze(expression);
1447
1447
  if (analysis.unsafe != null) {
1448
- throw `Unsafe expression detected: "${analysis.unsafe}" in "${expression}".`;
1448
+ throw new Error(`Unsafe expression detected: "${analysis.unsafe}" in "${expression}".`);
1449
1449
  }
1450
1450
  if (!analysis.hasReferences) {
1451
1451
  return { kind: "constant", functionBody: `return ${expression};`, voidBody: expression, dependencies: [] };
@@ -4415,6 +4415,14 @@ var SwipeEventArgsClass = class _SwipeEventArgsClass {
4415
4415
  get element() {
4416
4416
  return this._builder.element;
4417
4417
  }
4418
+ /**
4419
+ * @readonly Gets the snap the element is going to rest at, relative to where the gesture started: `0` means it
4420
+ * bounces back home (the release didn't make it). Known on release (`swipe`, `swipe<direction>` and the
4421
+ * animation-end events); `undefined` while panning.
4422
+ */
4423
+ get snap() {
4424
+ return this._builder.snap;
4425
+ }
4418
4426
  /** Builds a new {@link SwipeEventArgsClass} out of a plain {@link SwipeEventArgs} builder. */
4419
4427
  static fromArgs(builder) {
4420
4428
  return new _SwipeEventArgsClass(Utils.extend({}, builder));
@@ -4854,28 +4862,46 @@ var PacemUnsafeContentElement = class extends PacemContentElement {
4854
4862
  return html;
4855
4863
  }
4856
4864
  };
4865
+ var URL_ATTRIBUTES = ["href", "src", "action", "formaction", "xlink:href"];
4866
+ function isScriptUrl(value2) {
4867
+ const normalized = (value2 ?? "").replace(/[\u0000- ]/g, "").toLowerCase();
4868
+ return normalized.startsWith("javascript:");
4869
+ }
4870
+ function sanitizeNode(node) {
4871
+ for (let i = node.childNodes.length - 1; i >= 0; i--) {
4872
+ const child = node.childNodes.item(i);
4873
+ if (child instanceof Element && child.localName === "script") {
4874
+ child.remove();
4875
+ continue;
4876
+ }
4877
+ sanitizeNode(child);
4878
+ }
4879
+ if (!(node instanceof Element)) {
4880
+ return;
4881
+ }
4882
+ for (const attribute of Array.from(node.attributes)) {
4883
+ const name = attribute.name.toLowerCase();
4884
+ const isHandler = name.startsWith("on");
4885
+ const isScriptLink = URL_ATTRIBUTES.indexOf(name) >= 0 && isScriptUrl(attribute.value);
4886
+ if (isHandler || isScriptLink) {
4887
+ node.removeAttribute(attribute.name);
4888
+ }
4889
+ }
4890
+ }
4857
4891
  var PacemSafeContentElement = class extends PacemContentElement {
4858
- _sanitizeLegacy(html) {
4892
+ sanitize(html) {
4859
4893
  if (Utils.isNullOrEmpty(html)) {
4860
4894
  return html;
4861
4895
  }
4862
4896
  if (html instanceof Node) {
4863
- for (let i = html.childNodes.length - 1; i >= 0; i--) {
4864
- const node = html.childNodes.item(i);
4865
- if (node instanceof HTMLScriptElement) {
4866
- node.remove();
4867
- } else {
4868
- this.sanitize(node);
4869
- }
4870
- }
4897
+ sanitizeNode(html);
4871
4898
  return html;
4872
- } else {
4873
- const scriptBlockPattern = /<script.+<\/script>/g;
4874
- return (html || "").toString().replace(scriptBlockPattern, "");
4875
4899
  }
4876
- }
4877
- sanitize(html) {
4878
- return this._sanitizeLegacy(html);
4900
+ const template = document.createElement("template");
4901
+ template.innerHTML = html.toString();
4902
+ const fragment = template.content;
4903
+ sanitizeNode(fragment);
4904
+ return fragment;
4879
4905
  }
4880
4906
  };
4881
4907
 
@@ -5109,7 +5135,7 @@ var PacemBroadcastChannelProxyElement = class PacemBroadcastChannelProxyElement2
5109
5135
  super.propertyChangedCallback(name, old, val, first);
5110
5136
  if (!first) {
5111
5137
  switch (name) {
5112
- case "src":
5138
+ case "channelName":
5113
5139
  this._disposeChannel();
5114
5140
  this._initializeChannel(val);
5115
5141
  break;
@@ -5157,6 +5183,9 @@ var PacemBroadcastChannelProxyElement = class PacemBroadcastChannelProxyElement2
5157
5183
  channel.removeEventListener("message", this._messageHandler, false);
5158
5184
  channel.close();
5159
5185
  }
5186
+ if (channel === this.#channel) {
5187
+ this.#channel = null;
5188
+ }
5160
5189
  }
5161
5190
  };
5162
5191
  __decorate6([
@@ -5231,12 +5260,25 @@ var __decorate8 = function(decorators, target, key2, desc) {
5231
5260
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key2, r) : d(target, key2)) || r;
5232
5261
  return c > 3 && r && Object.defineProperty(target, key2, r), r;
5233
5262
  };
5263
+ var DebouncePropertyConverter = {
5264
+ convert: (attr) => {
5265
+ switch (attr) {
5266
+ case "true":
5267
+ return true;
5268
+ case "false":
5269
+ return false;
5270
+ default:
5271
+ return parseFloat(attr);
5272
+ }
5273
+ },
5274
+ convertBack: (prop) => `${prop}`
5275
+ };
5234
5276
  var PacemDataElement = class PacemDataElement2 extends PacemEventTarget {
5235
5277
  constructor(storage = new Storage()) {
5236
5278
  super();
5237
5279
  this.storage = storage;
5238
- this._handle = 0;
5239
- this._flag = false;
5280
+ this._cancelPending = null;
5281
+ this._throttling = false;
5240
5282
  }
5241
5283
  propertyChangedCallback(name, old, val, first) {
5242
5284
  super.propertyChangedCallback(name, old, val, first);
@@ -5250,34 +5292,65 @@ var PacemDataElement = class PacemDataElement2 extends PacemEventTarget {
5250
5292
  }
5251
5293
  break;
5252
5294
  case "model":
5253
- const debounce = this.debounce, throttle = this.throttle, emit = () => {
5254
- this.dispatchEvent(new PropertyChangeEvent({ propertyName: name, oldValue: old, currentValue: val, firstChange: first }));
5255
- };
5256
- if (debounce > 0 && !first) {
5257
- if (throttle) {
5258
- if (this._flag)
5259
- return;
5260
- this._flag = true;
5261
- emit();
5262
- this._handle = window.setTimeout(() => {
5263
- this._flag = false;
5264
- }, debounce);
5265
- } else {
5266
- clearTimeout(this._handle);
5267
- this._handle = window.setTimeout(emit, debounce);
5268
- }
5269
- } else {
5270
- emit();
5271
- }
5272
- if (!first && !Utils.isNullOrEmpty(this.persistAs)) {
5273
- if (Utils.isNull(val))
5274
- this.storage.removeProperty(this.persistAs);
5275
- else
5276
- this.storage.setPropertyValue(this.persistAs, val, true);
5277
- }
5295
+ this._notifyModelChange(old, val, first);
5296
+ this._persist(val, first);
5278
5297
  break;
5279
5298
  }
5280
5299
  }
5300
+ /** Notifies a model change: right away, debounced or throttled (see {@link debounce} and {@link throttle}). */
5301
+ _notifyModelChange(old, val, first) {
5302
+ const emit = () => {
5303
+ this.dispatchEvent(new PropertyChangeEvent({ propertyName: "model", oldValue: old, currentValue: val, firstChange: first }));
5304
+ };
5305
+ const debounce = this.debounce;
5306
+ const perFrame = debounce === true;
5307
+ const delay = typeof debounce === "number" && debounce > 0 ? debounce : 0;
5308
+ if (first || !perFrame && delay === 0) {
5309
+ emit();
5310
+ return;
5311
+ }
5312
+ if (this.throttle) {
5313
+ this._throttle(emit, perFrame, delay);
5314
+ return;
5315
+ }
5316
+ this._cancelPending?.();
5317
+ this._cancelPending = this._schedule(emit, perFrame, delay);
5318
+ }
5319
+ /** Notifies the first change of a window, and drops the others until the window closes. */
5320
+ _throttle(emit, perFrame, delay) {
5321
+ if (this._throttling) {
5322
+ return;
5323
+ }
5324
+ this._throttling = true;
5325
+ emit();
5326
+ this._schedule(() => {
5327
+ this._throttling = false;
5328
+ }, perFrame, delay);
5329
+ }
5330
+ /**
5331
+ * Runs a callback on the next animation frame, or after a delay.
5332
+ * @returns A function cancelling it.
5333
+ */
5334
+ _schedule(callback, perFrame, delay) {
5335
+ if (perFrame) {
5336
+ const frame = requestAnimationFrame(callback);
5337
+ return () => cancelAnimationFrame(frame);
5338
+ }
5339
+ const timeout = window.setTimeout(callback, delay);
5340
+ return () => clearTimeout(timeout);
5341
+ }
5342
+ /** Persists the model under {@link persistAs}, if set (a `null` model removes it). */
5343
+ _persist(val, first) {
5344
+ const key2 = this.persistAs;
5345
+ if (first || Utils.isNullOrEmpty(key2)) {
5346
+ return;
5347
+ }
5348
+ if (Utils.isNull(val)) {
5349
+ this.storage.removeProperty(key2);
5350
+ return;
5351
+ }
5352
+ this.storage.setPropertyValue(key2, val, true);
5353
+ }
5281
5354
  };
5282
5355
  __decorate8([
5283
5356
  Watch({ emit: false, converter: PropertyConverters.Eval })
@@ -5286,7 +5359,7 @@ __decorate8([
5286
5359
  Watch({ emit: false, converter: PropertyConverters.String })
5287
5360
  ], PacemDataElement.prototype, "persistAs", void 0);
5288
5361
  __decorate8([
5289
- Watch({ emit: false, converter: PropertyConverters.Number })
5362
+ Watch({ emit: false, converter: DebouncePropertyConverter })
5290
5363
  ], PacemDataElement.prototype, "debounce", void 0);
5291
5364
  __decorate8([
5292
5365
  Watch({ emit: false, converter: PropertyConverters.BooleanStrict })
@@ -5834,7 +5907,7 @@ __decorate12([
5834
5907
  Watch({ reflectBack: true, converter: PropertyConverters.Number })
5835
5908
  ], PacemFetchElement.prototype, "debounce", void 0);
5836
5909
  __decorate12([
5837
- Watch({ emit: false, reflectBack: true, converter: PropertyConverters.Number })
5910
+ Watch({ emit: false, reflectBack: true, converter: PropertyConverters.Boolean })
5838
5911
  ], PacemFetchElement.prototype, "throttle", void 0);
5839
5912
  __decorate12([
5840
5913
  Watch({ emit: false, reflectBack: true, converter: PropertyConverters.Boolean })
@@ -7122,6 +7195,8 @@ var PacemServiceWorkerProxyElement = class PacemServiceWorkerProxyElement2 exten
7122
7195
  this.pushSubscription = null;
7123
7196
  }
7124
7197
  resolve(result);
7198
+ }, (reason) => {
7199
+ reject(reason);
7125
7200
  });
7126
7201
  } else {
7127
7202
  resolve(false);
@@ -7131,6 +7206,8 @@ var PacemServiceWorkerProxyElement = class PacemServiceWorkerProxyElement2 exten
7131
7206
  /**
7132
7207
  * Subscribes to push notifications through the registered service worker.
7133
7208
  * @param publicKey VAPID public key (base64url or raw bytes); defaults to `publicKey`
7209
+ * @returns The subscription (`null` without a push manager, or when notifications are denied); rejects when the
7210
+ * browser refuses to subscribe (no push service, an invalid key…).
7134
7211
  */
7135
7212
  subscribe(publicKey = this.publicKey) {
7136
7213
  return new Promise((resolve, reject) => {
@@ -7151,6 +7228,8 @@ var PacemServiceWorkerProxyElement = class PacemServiceWorkerProxyElement2 exten
7151
7228
  this.pushSubscription = subscription
7152
7229
  );
7153
7230
  }
7231
+ }, (reason) => {
7232
+ reject(reason);
7154
7233
  });
7155
7234
  } else {
7156
7235
  resolve(null);
@@ -7216,6 +7295,10 @@ var PacemShortcutElement = class PacemShortcutElement2 extends PacemEventTarget
7216
7295
  super(...arguments);
7217
7296
  this._accumulator = [];
7218
7297
  this._shortcutHandler = (evt) => {
7298
+ if (this.disabled) {
7299
+ this._accumulator.splice(0);
7300
+ return;
7301
+ }
7219
7302
  const result = matchesKeyCombination(evt, this.combination, this._accumulator);
7220
7303
  switch (result) {
7221
7304
  case true:
@@ -7716,6 +7799,9 @@ var PacemWebWorkerProxyElement = class PacemWebWorkerProxyElement2 extends Pacem
7716
7799
  worker.removeEventListener("message", this._messageHandler, false);
7717
7800
  worker.terminate();
7718
7801
  }
7802
+ if (worker === this._worker) {
7803
+ this._worker = null;
7804
+ }
7719
7805
  }
7720
7806
  };
7721
7807
  __decorate36([
@@ -8192,6 +8278,28 @@ var __decorate38 = function(decorators, target, key2, desc) {
8192
8278
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key2, r) : d(target, key2)) || r;
8193
8279
  return c > 3 && r && Object.defineProperty(target, key2, r), r;
8194
8280
  };
8281
+ function clamp(value2, min, max) {
8282
+ if (value2 < min) {
8283
+ return min;
8284
+ }
8285
+ return Math.min(value2, max);
8286
+ }
8287
+ function clampToConstraints(rect, handle, constraints) {
8288
+ const width = clamp(rect.width, constraints.minWidth, constraints.maxWidth);
8289
+ const height = clamp(rect.height, constraints.minHeight, constraints.maxHeight);
8290
+ const x = handle.endsWith("left") ? rect.x + rect.width - width : rect.x;
8291
+ const y = handle.startsWith("top") ? rect.y + rect.height - height : rect.y;
8292
+ return { x, y, width, height };
8293
+ }
8294
+ function boxChrome(computed) {
8295
+ if (computed.boxSizing === "border-box") {
8296
+ return { width: 0, height: 0 };
8297
+ }
8298
+ const px = (value2) => parseFloat(value2) || 0;
8299
+ const width = px(computed.paddingLeft) + px(computed.paddingRight) + px(computed.borderLeftWidth) + px(computed.borderRightWidth);
8300
+ const height = px(computed.paddingTop) + px(computed.paddingBottom) + px(computed.borderTopWidth) + px(computed.borderBottomWidth);
8301
+ return { width, height };
8302
+ }
8195
8303
  var RescaleElementDelegate = class {
8196
8304
  constructor(_element, _type, _rescaler, _logFn) {
8197
8305
  this._element = _element;
@@ -8257,6 +8365,9 @@ var RescaleElementDelegate = class {
8257
8365
  this._logFn(LogLevel.Log, `handle: ${handle}, origin: ${JSON.stringify(origin)}, currentPosition: ${JSON.stringify(currentPosition)}`, `Rescaling`);
8258
8366
  this._logFn(LogLevel.Log, `delta: ${JSON.stringify(delta)}, position: ${JSON.stringify(position)}`, `Rescaling`);
8259
8367
  this._logFn(LogLevel.Log, `from: ${JSON.stringify(this._rect)}, to: ${JSON.stringify(desiredRect)}`, `Rescaling`);
8368
+ if (!keepProportions) {
8369
+ desiredRect = clampToConstraints(desiredRect, handle, { minWidth, maxWidth, minHeight, maxHeight });
8370
+ }
8260
8371
  let horizontally = desiredRect.width >= minWidth && desiredRect.width <= maxWidth, vertically = desiredRect.height >= minHeight && desiredRect.height <= maxHeight;
8261
8372
  if (keepProportions && (!horizontally || !vertically)) {
8262
8373
  horizontally = vertically = false;
@@ -8283,8 +8394,9 @@ var RescaleElementDelegate = class {
8283
8394
  if (!rescaleEvt.defaultPrevented) {
8284
8395
  const m = this._originalTransform;
8285
8396
  el.style.transform = `matrix(${m.a},${m.b},${m.c},${m.d},${m.e + desiredRect.x - this._rect.x},${m.f + desiredRect.y - this._rect.y})`;
8286
- el.style.width = desiredRect.width + "px";
8287
- el.style.height = desiredRect.height + "px";
8397
+ const chrome = this._chrome;
8398
+ el.style.width = Math.max(desiredRect.width - chrome.width, 0) + "px";
8399
+ el.style.height = Math.max(desiredRect.height - chrome.height, 0) + "px";
8288
8400
  }
8289
8401
  this._targetRect = desiredRect;
8290
8402
  }
@@ -8314,7 +8426,9 @@ var RescaleElementDelegate = class {
8314
8426
  window.addEventListener("touchmove", this._moveHandler, false);
8315
8427
  this._origin = this._position = GET_VAL5(_element, MOUSE_DOWN2);
8316
8428
  this._rect = this._targetRect = Utils.offsetRect(_element);
8317
- this._originalTransform = Utils.deserializeTransform(getComputedStyle(_element));
8429
+ const computed = getComputedStyle(_element);
8430
+ this._originalTransform = Utils.deserializeTransform(computed);
8431
+ this._chrome = boxChrome(computed);
8318
8432
  Utils.addClass(document.body, PCSS + "-rescaling rescale-" + _type);
8319
8433
  }
8320
8434
  };
@@ -8658,8 +8772,8 @@ var SwipeElementDelegate = class {
8658
8772
  swiper.dispatchEvent(swipeEvt);
8659
8773
  if (!swipeEvt.defaultPrevented) {
8660
8774
  let { delta } = this._delta(this._init, state);
8661
- if (!swiper.options.bouncy) {
8662
- const snaps = swiper.snaps.slice().sort();
8775
+ if (!this.#options.bouncy) {
8776
+ const snaps = swiper.snaps.slice().sort((a, b) => a - b);
8663
8777
  const snapFirst = snaps[0], snapLast = snaps[snaps.length - 1];
8664
8778
  const dir = this._swiper.direction;
8665
8779
  const { x, y } = delta;
@@ -8674,22 +8788,22 @@ var SwipeElementDelegate = class {
8674
8788
  if (Utils.isNull(this.#state)) {
8675
8789
  console.log("How come?!");
8676
8790
  } else {
8677
- const args = this._buildSwipeArgsFromState();
8678
- const swipeEvt = new SwipeEvent(SwipeEventType.Swipe, args, { cancelable: true, bubbles: false });
8679
8791
  const swiper = this._swiper;
8792
+ const estimate = this._buildSwipeArgsFromState();
8793
+ const snaps = (swiper.snaps ?? [0]).slice().sort((a, b) => a - b);
8794
+ const target = this.#options.bouncy ? estimate.predictedDelta : estimate.predictedDelta.clamp(snaps[0], snaps[snaps.length - 1]);
8795
+ const snap = snaps.reduce((acc, v) => {
8796
+ const distance = Math.abs(v - target);
8797
+ const current = Math.abs(acc - target);
8798
+ return distance < current ? v : acc;
8799
+ }, 0);
8800
+ const args = this._buildSwipeArgsFromState(this.#state, snap);
8801
+ const swipeEvt = new SwipeEvent(SwipeEventType.Swipe, args, { cancelable: true, bubbles: false });
8680
8802
  swiper.dispatchEvent(swipeEvt);
8681
8803
  if (!swipeEvt.defaultPrevented) {
8682
8804
  const swipe1Evt = new SwipeEvent("swipe" + args.direction, args, { cancelable: true, bubbles: false });
8683
8805
  swiper.dispatchEvent(swipe1Evt);
8684
8806
  if (!swipe1Evt.defaultPrevented) {
8685
- const snaps = swiper.snaps ?? [0];
8686
- snaps.sort();
8687
- const target = swiper.options.bouncy ? args.predictedDelta : args.predictedDelta.clamp(snaps[0], snaps[snaps.length - 1]);
8688
- const snap = snaps.reduce((acc, v) => {
8689
- const distance = Math.abs(v - target);
8690
- const current = Math.abs(acc - target);
8691
- return distance < current ? v : acc;
8692
- }, 0);
8693
8807
  const vertical = swiper.direction === "vertical";
8694
8808
  const duration = args.predictedDuration;
8695
8809
  const delta0 = vertical ? { x: 0, y: target } : { x: target, y: 0 };
@@ -8702,7 +8816,10 @@ var SwipeElementDelegate = class {
8702
8816
  };
8703
8817
  if (snap.isCloseTo(0)) {
8704
8818
  this._animateOffsetBy(delta0, duration).then(() => {
8705
- this._animateOffsetBy({ x: 0, y: 0 }, 0.3, "cubic-bezier(.37,-0.01,.34,1.43)").then(() => swipeAnimationEnd());
8819
+ this._animateOffsetBy({ x: 0, y: 0 }, 0.3, "cubic-bezier(.37,-0.01,.34,1.43)").then(() => {
8820
+ this._element.style.transform = this.#originalInlineTransform;
8821
+ swipeAnimationEnd();
8822
+ });
8706
8823
  });
8707
8824
  } else {
8708
8825
  const doesNotExceed = (snap - target) * (snap - args.delta) >= 0;
@@ -8727,6 +8844,7 @@ var SwipeElementDelegate = class {
8727
8844
  const el = _element;
8728
8845
  this.#options = Utils.extend({}, DEFAULT_OPTIONS, _swiper.options ?? {});
8729
8846
  this.#originalTransform = Utils.deserializeTransform(getComputedStyle(el));
8847
+ this.#originalInlineTransform = el.style.transform;
8730
8848
  window.addEventListener("pointermove", this._moveHandler, false);
8731
8849
  window.addEventListener("pointerup", this._endHandler, false);
8732
8850
  window.addEventListener("pointercancel", this._endHandler, false);
@@ -8765,7 +8883,12 @@ var SwipeElementDelegate = class {
8765
8883
  };
8766
8884
  return state;
8767
8885
  }
8768
- _buildSwipeArgsFromState(state = this.#state) {
8886
+ /**
8887
+ * Builds the event args of the current state.
8888
+ * @param state The gesture state.
8889
+ * @param snap The snap the element is going to rest at, once known (on release).
8890
+ */
8891
+ _buildSwipeArgsFromState(state = this.#state, snap) {
8769
8892
  const options = this.#options;
8770
8893
  const speed = this.speed;
8771
8894
  const dir = this._swiper.direction;
@@ -8780,7 +8903,8 @@ var SwipeElementDelegate = class {
8780
8903
  fling: options.fling,
8781
8904
  horizontalspeed,
8782
8905
  verticalspeed,
8783
- vertical
8906
+ vertical,
8907
+ snap
8784
8908
  });
8785
8909
  return args;
8786
8910
  }
@@ -8806,6 +8930,8 @@ var SwipeElementDelegate = class {
8806
8930
  #options;
8807
8931
  #samples;
8808
8932
  #originalTransform;
8933
+ /** The element's inline `transform` before the gesture, restored as is on a bounce-back home. */
8934
+ #originalInlineTransform;
8809
8935
  #state;
8810
8936
  dispose() {
8811
8937
  const el = this._element;