@capgo/capacitor-transitions 8.0.2 → 8.0.3
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 +7 -0
- package/dist/{chunk-X3P7VCWP.mjs → chunk-LABKGL2K.mjs} +68 -12
- package/dist/chunk-LABKGL2K.mjs.map +1 -0
- package/dist/{components-OPL2TMTE.mjs → components-M5B63NYZ.mjs} +2 -2
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +67 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/react/index.js +67 -11
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +67 -11
- package/dist/react/index.mjs.map +1 -1
- package/dist/solid/index.js +67 -11
- package/dist/solid/index.js.map +1 -1
- package/dist/solid/index.mjs +67 -11
- package/dist/solid/index.mjs.map +1 -1
- package/dist/svelte/index.js +67 -11
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/index.mjs +67 -11
- package/dist/svelte/index.mjs.map +1 -1
- package/dist/vue/index.js +67 -11
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/index.mjs +67 -11
- package/dist/vue/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-X3P7VCWP.mjs.map +0 -1
- /package/dist/{components-OPL2TMTE.mjs.map → components-M5B63NYZ.mjs.map} +0 -0
package/dist/svelte/index.js
CHANGED
|
@@ -830,12 +830,15 @@ var TransitionController = class {
|
|
|
830
830
|
animation.pause();
|
|
831
831
|
animation.currentTime = 0;
|
|
832
832
|
}
|
|
833
|
+
const animationDurations = animations.map((animation) => this.getAnimationDuration(animation, duration));
|
|
833
834
|
this.currentAnimations = animations;
|
|
834
835
|
this.interactiveBackTransition = {
|
|
835
836
|
enteringState,
|
|
836
837
|
leavingState,
|
|
837
838
|
animations,
|
|
838
|
-
|
|
839
|
+
animationDurations,
|
|
840
|
+
duration,
|
|
841
|
+
progress: 0
|
|
839
842
|
};
|
|
840
843
|
return true;
|
|
841
844
|
}
|
|
@@ -848,9 +851,12 @@ var TransitionController = class {
|
|
|
848
851
|
return;
|
|
849
852
|
}
|
|
850
853
|
const progress = Math.max(0, Math.min(step, 0.9999));
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
+
if (Math.abs(progress - transition.progress) < 5e-4) {
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
transition.progress = progress;
|
|
858
|
+
for (const [index, animation] of transition.animations.entries()) {
|
|
859
|
+
const duration = transition.animationDurations[index] ?? transition.duration;
|
|
854
860
|
animation.currentTime = duration * progress;
|
|
855
861
|
}
|
|
856
862
|
}
|
|
@@ -1029,15 +1035,16 @@ var TransitionController = class {
|
|
|
1029
1035
|
return;
|
|
1030
1036
|
}
|
|
1031
1037
|
if (releaseDuration <= 0) {
|
|
1032
|
-
|
|
1033
|
-
|
|
1038
|
+
transition.progress = targetProgress;
|
|
1039
|
+
for (const [index, animation] of transition.animations.entries()) {
|
|
1040
|
+
const duration = transition.animationDurations[index] ?? transition.duration;
|
|
1034
1041
|
animation.pause();
|
|
1035
1042
|
animation.currentTime = duration * targetProgress;
|
|
1036
1043
|
}
|
|
1037
1044
|
return;
|
|
1038
1045
|
}
|
|
1039
|
-
const finished = transition.animations.map((animation) => {
|
|
1040
|
-
const duration =
|
|
1046
|
+
const finished = transition.animations.map((animation, index) => {
|
|
1047
|
+
const duration = transition.animationDurations[index] ?? transition.duration;
|
|
1041
1048
|
const currentTime = typeof animation.currentTime === "number" ? animation.currentTime : 0;
|
|
1042
1049
|
const targetTime = duration * targetProgress;
|
|
1043
1050
|
const distance = Math.abs(targetTime - currentTime);
|
|
@@ -1050,6 +1057,7 @@ var TransitionController = class {
|
|
|
1050
1057
|
return animation.finished.catch(() => void 0);
|
|
1051
1058
|
});
|
|
1052
1059
|
await Promise.all(finished);
|
|
1060
|
+
transition.progress = targetProgress;
|
|
1053
1061
|
}
|
|
1054
1062
|
/**
|
|
1055
1063
|
* Resolve configured easing presets after platform/direction are known.
|
|
@@ -1239,6 +1247,8 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1239
1247
|
pendingPage = null;
|
|
1240
1248
|
ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1241
1249
|
swipeGesturePointer = null;
|
|
1250
|
+
swipeGestureFrame = 0;
|
|
1251
|
+
swipeGesturePendingStep = null;
|
|
1242
1252
|
swipeGestureListenersActive = false;
|
|
1243
1253
|
skipNextHistoryBackTransition = false;
|
|
1244
1254
|
swipeBackDepth = 0;
|
|
@@ -1281,6 +1291,7 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1281
1291
|
this.style.width = "100%";
|
|
1282
1292
|
this.style.height = "100%";
|
|
1283
1293
|
this.style.overflow = "hidden";
|
|
1294
|
+
this.style.overscrollBehaviorX = "contain";
|
|
1284
1295
|
this.lastNavigationHref = this.getCurrentNavigationHref();
|
|
1285
1296
|
this.lastNavigationPosition = this.getCurrentNavigationPosition();
|
|
1286
1297
|
this.ownerDocument.defaultView?.addEventListener("popstate", this.handleHistoryPopState);
|
|
@@ -1588,6 +1599,10 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1588
1599
|
this.removeEventListener("pointerup", this.handleSwipeGesturePointerEnd);
|
|
1589
1600
|
this.removeEventListener("pointercancel", this.handleSwipeGesturePointerCancel);
|
|
1590
1601
|
this.swipeGestureListenersActive = false;
|
|
1602
|
+
this.clearQueuedSwipeGestureStep();
|
|
1603
|
+
if (this.swipeGesturePointer?.transitionStarted) {
|
|
1604
|
+
this.controller.cancelInteractiveBack();
|
|
1605
|
+
}
|
|
1591
1606
|
this.swipeGesturePointer = null;
|
|
1592
1607
|
}
|
|
1593
1608
|
isSwipeGestureEnabled() {
|
|
@@ -1780,12 +1795,14 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1780
1795
|
if (!this.canStartSwipeGesture(event)) {
|
|
1781
1796
|
return;
|
|
1782
1797
|
}
|
|
1798
|
+
const width = Math.max(this.getBoundingClientRect().width, 1);
|
|
1783
1799
|
this.swipeGesturePointer = {
|
|
1784
1800
|
pointerId: event.pointerId,
|
|
1785
1801
|
startX: event.clientX,
|
|
1786
1802
|
startY: event.clientY,
|
|
1787
1803
|
currentX: event.clientX,
|
|
1788
1804
|
currentY: event.clientY,
|
|
1805
|
+
width,
|
|
1789
1806
|
startTime: performance.now(),
|
|
1790
1807
|
dragging: false,
|
|
1791
1808
|
transitionStarted: false
|
|
@@ -1832,8 +1849,7 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1832
1849
|
return;
|
|
1833
1850
|
}
|
|
1834
1851
|
if (event.cancelable) event.preventDefault();
|
|
1835
|
-
|
|
1836
|
-
this.controller.stepInteractiveBack(deltaX / width);
|
|
1852
|
+
this.queueSwipeGestureStep(deltaX / pointer.width);
|
|
1837
1853
|
}
|
|
1838
1854
|
};
|
|
1839
1855
|
handleSwipeGesturePointerEnd = (event) => {
|
|
@@ -1846,12 +1862,17 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1846
1862
|
const deltaX = this.getSwipeGestureDeltaX(pointer);
|
|
1847
1863
|
const elapsed = Math.max(performance.now() - pointer.startTime, 1);
|
|
1848
1864
|
const velocityX = deltaX / elapsed;
|
|
1849
|
-
const width =
|
|
1865
|
+
const width = pointer.width;
|
|
1850
1866
|
const step = deltaX / width;
|
|
1851
1867
|
const shouldCommit = pointer.dragging && pointer.transitionStarted && velocityX >= 0 && (velocityX > this.swipeGestureMinimumVelocity || deltaX > width / 2);
|
|
1852
1868
|
const missing = shouldCommit ? 1 - step : step;
|
|
1853
1869
|
const missingDistance = Math.max(missing, 0) * width;
|
|
1854
1870
|
const releaseDuration = missingDistance > 5 && Math.abs(velocityX) > 0 ? Math.min(missingDistance / Math.abs(velocityX), 540) : 0;
|
|
1871
|
+
if (pointer.transitionStarted) {
|
|
1872
|
+
this.flushQueuedSwipeGestureStep();
|
|
1873
|
+
} else {
|
|
1874
|
+
this.clearQueuedSwipeGestureStep();
|
|
1875
|
+
}
|
|
1855
1876
|
this.releaseSwipeGesturePointer(event.pointerId);
|
|
1856
1877
|
void this.finishSwipeGestureBack(shouldCommit, releaseDuration);
|
|
1857
1878
|
};
|
|
@@ -1859,6 +1880,7 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1859
1880
|
this.cancelSwipeGesture(event.pointerId);
|
|
1860
1881
|
};
|
|
1861
1882
|
cancelSwipeGesturePointer(pointerId) {
|
|
1883
|
+
this.clearQueuedSwipeGestureStep();
|
|
1862
1884
|
this.releaseSwipeGesturePointer(pointerId);
|
|
1863
1885
|
}
|
|
1864
1886
|
releaseSwipeGesturePointer(pointerId) {
|
|
@@ -1877,10 +1899,44 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1877
1899
|
return;
|
|
1878
1900
|
}
|
|
1879
1901
|
this.releaseSwipeGesturePointer(pointerId);
|
|
1902
|
+
this.clearQueuedSwipeGestureStep();
|
|
1880
1903
|
if (pointer.transitionStarted) {
|
|
1881
1904
|
void this.finishSwipeGestureBack(false, 0);
|
|
1882
1905
|
}
|
|
1883
1906
|
}
|
|
1907
|
+
queueSwipeGestureStep(step) {
|
|
1908
|
+
this.swipeGesturePendingStep = step;
|
|
1909
|
+
if (this.swipeGestureFrame !== 0) {
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
const win = this.ownerDocument.defaultView;
|
|
1913
|
+
if (!win) {
|
|
1914
|
+
this.flushQueuedSwipeGestureStep();
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1917
|
+
this.swipeGestureFrame = win.requestAnimationFrame(() => {
|
|
1918
|
+
this.swipeGestureFrame = 0;
|
|
1919
|
+
this.flushQueuedSwipeGestureStep();
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
1922
|
+
flushQueuedSwipeGestureStep() {
|
|
1923
|
+
const step = this.swipeGesturePendingStep;
|
|
1924
|
+
this.swipeGesturePendingStep = null;
|
|
1925
|
+
if (this.swipeGestureFrame !== 0) {
|
|
1926
|
+
this.ownerDocument.defaultView?.cancelAnimationFrame(this.swipeGestureFrame);
|
|
1927
|
+
this.swipeGestureFrame = 0;
|
|
1928
|
+
}
|
|
1929
|
+
if (step !== null) {
|
|
1930
|
+
this.controller.stepInteractiveBack(step);
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
clearQueuedSwipeGestureStep() {
|
|
1934
|
+
if (this.swipeGestureFrame !== 0) {
|
|
1935
|
+
this.ownerDocument.defaultView?.cancelAnimationFrame(this.swipeGestureFrame);
|
|
1936
|
+
this.swipeGestureFrame = 0;
|
|
1937
|
+
}
|
|
1938
|
+
this.swipeGesturePendingStep = null;
|
|
1939
|
+
}
|
|
1884
1940
|
async finishSwipeGestureBack(shouldComplete, releaseDuration) {
|
|
1885
1941
|
const canComplete = shouldComplete && this.getSwipeBackDestination() !== null;
|
|
1886
1942
|
const shouldUseHistory = canComplete && typeof window !== "undefined" && window.history.length > 1;
|