@capgo/capacitor-transitions 8.1.7 → 8.1.9

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.
@@ -677,6 +677,8 @@ var DEFAULT_CONFIG = {
677
677
  useViewTransitions: false,
678
678
  detectPlatform
679
679
  };
680
+ var IOS_RELEASE_EASING = "cubic-bezier(0.32, 0.72, 0, 1)";
681
+ var IOS_CANCEL_EASING = "cubic-bezier(1, 0, 0.68, 0.28)";
680
682
  var TransitionController = class {
681
683
  config;
682
684
  pageStack = [];
@@ -1045,8 +1047,13 @@ var TransitionController = class {
1045
1047
  }
1046
1048
  return;
1047
1049
  }
1050
+ const releaseEasing = targetProgress === 1 ? IOS_RELEASE_EASING : IOS_CANCEL_EASING;
1048
1051
  const finished = transition.animations.map((animation, index) => {
1049
1052
  const duration = transition.animationDurations[index] ?? transition.duration;
1053
+ this.applyInteractiveReleaseEasing(animation, releaseEasing);
1054
+ const currentProgress = duration > 0 ? transition.progress : targetProgress;
1055
+ const easedStep = this.getIOSReleaseTimeForProgress(currentProgress, targetProgress);
1056
+ animation.currentTime = duration * easedStep;
1050
1057
  const currentTime = typeof animation.currentTime === "number" ? animation.currentTime : 0;
1051
1058
  const targetTime = duration * targetProgress;
1052
1059
  const distance = Math.abs(targetTime - currentTime);
@@ -1061,6 +1068,33 @@ var TransitionController = class {
1061
1068
  await Promise.all(finished);
1062
1069
  transition.progress = targetProgress;
1063
1070
  }
1071
+ applyInteractiveReleaseEasing(animation, easing) {
1072
+ animation.effect?.updateTiming({ easing });
1073
+ }
1074
+ getIOSReleaseTimeForProgress(progress, targetProgress) {
1075
+ const clampedProgress = Math.max(0, Math.min(progress, 0.9999));
1076
+ if (targetProgress === 1) {
1077
+ return this.getCubicBezierTimeForProgress(clampedProgress, 0.32, 0.72, 0, 1);
1078
+ }
1079
+ return this.getCubicBezierTimeForProgress(clampedProgress, 1, 0, 0.68, 0.28);
1080
+ }
1081
+ getCubicBezierTimeForProgress(progress, x1, y1, x2, y2) {
1082
+ let low = 0;
1083
+ let high = 1;
1084
+ for (let iteration = 0; iteration < 16; iteration += 1) {
1085
+ const mid = (low + high) / 2;
1086
+ if (this.sampleCubicBezier(mid, y1, y2) < progress) {
1087
+ low = mid;
1088
+ } else {
1089
+ high = mid;
1090
+ }
1091
+ }
1092
+ return this.sampleCubicBezier((low + high) / 2, x1, x2);
1093
+ }
1094
+ sampleCubicBezier(time, point1, point2) {
1095
+ const inverseTime = 1 - time;
1096
+ return 3 * inverseTime * inverseTime * time * point1 + 3 * inverseTime * time * time * point2 + time * time * time;
1097
+ }
1064
1098
  /**
1065
1099
  * Resolve configured easing presets after platform/direction are known.
1066
1100
  */
@@ -1848,6 +1882,7 @@ var CapRouterOutlet = class extends HTMLElement {
1848
1882
  this.cancelSwipeGesture(event.pointerId);
1849
1883
  return;
1850
1884
  }
1885
+ let transitionStartedOnThisMove = false;
1851
1886
  if (!pointer.dragging && deltaX > this.swipeGestureThreshold && absX > absY) {
1852
1887
  if (!this.getSwipeBackDestination()) {
1853
1888
  this.cancelSwipeGesturePointer(event.pointerId);
@@ -1855,6 +1890,7 @@ var CapRouterOutlet = class extends HTMLElement {
1855
1890
  }
1856
1891
  pointer.dragging = true;
1857
1892
  pointer.transitionStarted = this.controller.beginInteractiveBack({ direction: "back" });
1893
+ transitionStartedOnThisMove = pointer.transitionStarted;
1858
1894
  if (!pointer.transitionStarted) {
1859
1895
  this.cancelSwipeGesturePointer(event.pointerId);
1860
1896
  return;
@@ -1866,7 +1902,12 @@ var CapRouterOutlet = class extends HTMLElement {
1866
1902
  return;
1867
1903
  }
1868
1904
  if (event.cancelable) event.preventDefault();
1869
- this.queueSwipeGestureStep(deltaX / pointer.width);
1905
+ const step = deltaX / pointer.width;
1906
+ if (transitionStartedOnThisMove) {
1907
+ this.controller.stepInteractiveBack(step);
1908
+ } else {
1909
+ this.queueSwipeGestureStep(step);
1910
+ }
1870
1911
  }
1871
1912
  };
1872
1913
  handleSwipeGesturePointerEnd = (event) => {