@capgo/capacitor-transitions 8.0.2 → 8.0.4
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 +11 -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/vue/index.mjs
CHANGED
|
@@ -796,12 +796,15 @@ var TransitionController = class {
|
|
|
796
796
|
animation.pause();
|
|
797
797
|
animation.currentTime = 0;
|
|
798
798
|
}
|
|
799
|
+
const animationDurations = animations.map((animation) => this.getAnimationDuration(animation, duration));
|
|
799
800
|
this.currentAnimations = animations;
|
|
800
801
|
this.interactiveBackTransition = {
|
|
801
802
|
enteringState,
|
|
802
803
|
leavingState,
|
|
803
804
|
animations,
|
|
804
|
-
|
|
805
|
+
animationDurations,
|
|
806
|
+
duration,
|
|
807
|
+
progress: 0
|
|
805
808
|
};
|
|
806
809
|
return true;
|
|
807
810
|
}
|
|
@@ -814,9 +817,12 @@ var TransitionController = class {
|
|
|
814
817
|
return;
|
|
815
818
|
}
|
|
816
819
|
const progress = Math.max(0, Math.min(step, 0.9999));
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
+
if (Math.abs(progress - transition.progress) < 5e-4) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
transition.progress = progress;
|
|
824
|
+
for (const [index, animation] of transition.animations.entries()) {
|
|
825
|
+
const duration = transition.animationDurations[index] ?? transition.duration;
|
|
820
826
|
animation.currentTime = duration * progress;
|
|
821
827
|
}
|
|
822
828
|
}
|
|
@@ -995,15 +1001,16 @@ var TransitionController = class {
|
|
|
995
1001
|
return;
|
|
996
1002
|
}
|
|
997
1003
|
if (releaseDuration <= 0) {
|
|
998
|
-
|
|
999
|
-
|
|
1004
|
+
transition.progress = targetProgress;
|
|
1005
|
+
for (const [index, animation] of transition.animations.entries()) {
|
|
1006
|
+
const duration = transition.animationDurations[index] ?? transition.duration;
|
|
1000
1007
|
animation.pause();
|
|
1001
1008
|
animation.currentTime = duration * targetProgress;
|
|
1002
1009
|
}
|
|
1003
1010
|
return;
|
|
1004
1011
|
}
|
|
1005
|
-
const finished = transition.animations.map((animation) => {
|
|
1006
|
-
const duration =
|
|
1012
|
+
const finished = transition.animations.map((animation, index) => {
|
|
1013
|
+
const duration = transition.animationDurations[index] ?? transition.duration;
|
|
1007
1014
|
const currentTime = typeof animation.currentTime === "number" ? animation.currentTime : 0;
|
|
1008
1015
|
const targetTime = duration * targetProgress;
|
|
1009
1016
|
const distance = Math.abs(targetTime - currentTime);
|
|
@@ -1016,6 +1023,7 @@ var TransitionController = class {
|
|
|
1016
1023
|
return animation.finished.catch(() => void 0);
|
|
1017
1024
|
});
|
|
1018
1025
|
await Promise.all(finished);
|
|
1026
|
+
transition.progress = targetProgress;
|
|
1019
1027
|
}
|
|
1020
1028
|
/**
|
|
1021
1029
|
* Resolve configured easing presets after platform/direction are known.
|
|
@@ -1205,6 +1213,8 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1205
1213
|
pendingPage = null;
|
|
1206
1214
|
ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1207
1215
|
swipeGesturePointer = null;
|
|
1216
|
+
swipeGestureFrame = 0;
|
|
1217
|
+
swipeGesturePendingStep = null;
|
|
1208
1218
|
swipeGestureListenersActive = false;
|
|
1209
1219
|
skipNextHistoryBackTransition = false;
|
|
1210
1220
|
swipeBackDepth = 0;
|
|
@@ -1247,6 +1257,7 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1247
1257
|
this.style.width = "100%";
|
|
1248
1258
|
this.style.height = "100%";
|
|
1249
1259
|
this.style.overflow = "hidden";
|
|
1260
|
+
this.style.overscrollBehaviorX = "contain";
|
|
1250
1261
|
this.lastNavigationHref = this.getCurrentNavigationHref();
|
|
1251
1262
|
this.lastNavigationPosition = this.getCurrentNavigationPosition();
|
|
1252
1263
|
this.ownerDocument.defaultView?.addEventListener("popstate", this.handleHistoryPopState);
|
|
@@ -1554,6 +1565,10 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1554
1565
|
this.removeEventListener("pointerup", this.handleSwipeGesturePointerEnd);
|
|
1555
1566
|
this.removeEventListener("pointercancel", this.handleSwipeGesturePointerCancel);
|
|
1556
1567
|
this.swipeGestureListenersActive = false;
|
|
1568
|
+
this.clearQueuedSwipeGestureStep();
|
|
1569
|
+
if (this.swipeGesturePointer?.transitionStarted) {
|
|
1570
|
+
this.controller.cancelInteractiveBack();
|
|
1571
|
+
}
|
|
1557
1572
|
this.swipeGesturePointer = null;
|
|
1558
1573
|
}
|
|
1559
1574
|
isSwipeGestureEnabled() {
|
|
@@ -1746,12 +1761,14 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1746
1761
|
if (!this.canStartSwipeGesture(event)) {
|
|
1747
1762
|
return;
|
|
1748
1763
|
}
|
|
1764
|
+
const width = Math.max(this.getBoundingClientRect().width, 1);
|
|
1749
1765
|
this.swipeGesturePointer = {
|
|
1750
1766
|
pointerId: event.pointerId,
|
|
1751
1767
|
startX: event.clientX,
|
|
1752
1768
|
startY: event.clientY,
|
|
1753
1769
|
currentX: event.clientX,
|
|
1754
1770
|
currentY: event.clientY,
|
|
1771
|
+
width,
|
|
1755
1772
|
startTime: performance.now(),
|
|
1756
1773
|
dragging: false,
|
|
1757
1774
|
transitionStarted: false
|
|
@@ -1798,8 +1815,7 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1798
1815
|
return;
|
|
1799
1816
|
}
|
|
1800
1817
|
if (event.cancelable) event.preventDefault();
|
|
1801
|
-
|
|
1802
|
-
this.controller.stepInteractiveBack(deltaX / width);
|
|
1818
|
+
this.queueSwipeGestureStep(deltaX / pointer.width);
|
|
1803
1819
|
}
|
|
1804
1820
|
};
|
|
1805
1821
|
handleSwipeGesturePointerEnd = (event) => {
|
|
@@ -1812,12 +1828,17 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1812
1828
|
const deltaX = this.getSwipeGestureDeltaX(pointer);
|
|
1813
1829
|
const elapsed = Math.max(performance.now() - pointer.startTime, 1);
|
|
1814
1830
|
const velocityX = deltaX / elapsed;
|
|
1815
|
-
const width =
|
|
1831
|
+
const width = pointer.width;
|
|
1816
1832
|
const step = deltaX / width;
|
|
1817
1833
|
const shouldCommit = pointer.dragging && pointer.transitionStarted && velocityX >= 0 && (velocityX > this.swipeGestureMinimumVelocity || deltaX > width / 2);
|
|
1818
1834
|
const missing = shouldCommit ? 1 - step : step;
|
|
1819
1835
|
const missingDistance = Math.max(missing, 0) * width;
|
|
1820
1836
|
const releaseDuration = missingDistance > 5 && Math.abs(velocityX) > 0 ? Math.min(missingDistance / Math.abs(velocityX), 540) : 0;
|
|
1837
|
+
if (pointer.transitionStarted) {
|
|
1838
|
+
this.flushQueuedSwipeGestureStep();
|
|
1839
|
+
} else {
|
|
1840
|
+
this.clearQueuedSwipeGestureStep();
|
|
1841
|
+
}
|
|
1821
1842
|
this.releaseSwipeGesturePointer(event.pointerId);
|
|
1822
1843
|
void this.finishSwipeGestureBack(shouldCommit, releaseDuration);
|
|
1823
1844
|
};
|
|
@@ -1825,6 +1846,7 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1825
1846
|
this.cancelSwipeGesture(event.pointerId);
|
|
1826
1847
|
};
|
|
1827
1848
|
cancelSwipeGesturePointer(pointerId) {
|
|
1849
|
+
this.clearQueuedSwipeGestureStep();
|
|
1828
1850
|
this.releaseSwipeGesturePointer(pointerId);
|
|
1829
1851
|
}
|
|
1830
1852
|
releaseSwipeGesturePointer(pointerId) {
|
|
@@ -1843,10 +1865,44 @@ var CapRouterOutlet = class extends HTMLElement {
|
|
|
1843
1865
|
return;
|
|
1844
1866
|
}
|
|
1845
1867
|
this.releaseSwipeGesturePointer(pointerId);
|
|
1868
|
+
this.clearQueuedSwipeGestureStep();
|
|
1846
1869
|
if (pointer.transitionStarted) {
|
|
1847
1870
|
void this.finishSwipeGestureBack(false, 0);
|
|
1848
1871
|
}
|
|
1849
1872
|
}
|
|
1873
|
+
queueSwipeGestureStep(step) {
|
|
1874
|
+
this.swipeGesturePendingStep = step;
|
|
1875
|
+
if (this.swipeGestureFrame !== 0) {
|
|
1876
|
+
return;
|
|
1877
|
+
}
|
|
1878
|
+
const win = this.ownerDocument.defaultView;
|
|
1879
|
+
if (!win) {
|
|
1880
|
+
this.flushQueuedSwipeGestureStep();
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
this.swipeGestureFrame = win.requestAnimationFrame(() => {
|
|
1884
|
+
this.swipeGestureFrame = 0;
|
|
1885
|
+
this.flushQueuedSwipeGestureStep();
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
flushQueuedSwipeGestureStep() {
|
|
1889
|
+
const step = this.swipeGesturePendingStep;
|
|
1890
|
+
this.swipeGesturePendingStep = null;
|
|
1891
|
+
if (this.swipeGestureFrame !== 0) {
|
|
1892
|
+
this.ownerDocument.defaultView?.cancelAnimationFrame(this.swipeGestureFrame);
|
|
1893
|
+
this.swipeGestureFrame = 0;
|
|
1894
|
+
}
|
|
1895
|
+
if (step !== null) {
|
|
1896
|
+
this.controller.stepInteractiveBack(step);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
clearQueuedSwipeGestureStep() {
|
|
1900
|
+
if (this.swipeGestureFrame !== 0) {
|
|
1901
|
+
this.ownerDocument.defaultView?.cancelAnimationFrame(this.swipeGestureFrame);
|
|
1902
|
+
this.swipeGestureFrame = 0;
|
|
1903
|
+
}
|
|
1904
|
+
this.swipeGesturePendingStep = null;
|
|
1905
|
+
}
|
|
1850
1906
|
async finishSwipeGestureBack(shouldComplete, releaseDuration) {
|
|
1851
1907
|
const canComplete = shouldComplete && this.getSwipeBackDestination() !== null;
|
|
1852
1908
|
const shouldUseHistory = canComplete && typeof window !== "undefined" && window.history.length > 1;
|