@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/index.js
CHANGED
|
@@ -943,12 +943,15 @@ var init_transition_controller = __esm({
|
|
|
943
943
|
animation.pause();
|
|
944
944
|
animation.currentTime = 0;
|
|
945
945
|
}
|
|
946
|
+
const animationDurations = animations.map((animation) => this.getAnimationDuration(animation, duration));
|
|
946
947
|
this.currentAnimations = animations;
|
|
947
948
|
this.interactiveBackTransition = {
|
|
948
949
|
enteringState,
|
|
949
950
|
leavingState,
|
|
950
951
|
animations,
|
|
951
|
-
|
|
952
|
+
animationDurations,
|
|
953
|
+
duration,
|
|
954
|
+
progress: 0
|
|
952
955
|
};
|
|
953
956
|
return true;
|
|
954
957
|
}
|
|
@@ -961,9 +964,12 @@ var init_transition_controller = __esm({
|
|
|
961
964
|
return;
|
|
962
965
|
}
|
|
963
966
|
const progress = Math.max(0, Math.min(step, 0.9999));
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
+
if (Math.abs(progress - transition.progress) < 5e-4) {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
transition.progress = progress;
|
|
971
|
+
for (const [index, animation] of transition.animations.entries()) {
|
|
972
|
+
const duration = transition.animationDurations[index] ?? transition.duration;
|
|
967
973
|
animation.currentTime = duration * progress;
|
|
968
974
|
}
|
|
969
975
|
}
|
|
@@ -1142,15 +1148,16 @@ var init_transition_controller = __esm({
|
|
|
1142
1148
|
return;
|
|
1143
1149
|
}
|
|
1144
1150
|
if (releaseDuration <= 0) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1151
|
+
transition.progress = targetProgress;
|
|
1152
|
+
for (const [index, animation] of transition.animations.entries()) {
|
|
1153
|
+
const duration = transition.animationDurations[index] ?? transition.duration;
|
|
1147
1154
|
animation.pause();
|
|
1148
1155
|
animation.currentTime = duration * targetProgress;
|
|
1149
1156
|
}
|
|
1150
1157
|
return;
|
|
1151
1158
|
}
|
|
1152
|
-
const finished = transition.animations.map((animation) => {
|
|
1153
|
-
const duration =
|
|
1159
|
+
const finished = transition.animations.map((animation, index) => {
|
|
1160
|
+
const duration = transition.animationDurations[index] ?? transition.duration;
|
|
1154
1161
|
const currentTime = typeof animation.currentTime === "number" ? animation.currentTime : 0;
|
|
1155
1162
|
const targetTime = duration * targetProgress;
|
|
1156
1163
|
const distance = Math.abs(targetTime - currentTime);
|
|
@@ -1163,6 +1170,7 @@ var init_transition_controller = __esm({
|
|
|
1163
1170
|
return animation.finished.catch(() => void 0);
|
|
1164
1171
|
});
|
|
1165
1172
|
await Promise.all(finished);
|
|
1173
|
+
transition.progress = targetProgress;
|
|
1166
1174
|
}
|
|
1167
1175
|
/**
|
|
1168
1176
|
* Resolve configured easing presets after platform/direction are known.
|
|
@@ -1334,6 +1342,8 @@ var init_cap_router_outlet = __esm({
|
|
|
1334
1342
|
pendingPage = null;
|
|
1335
1343
|
ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1336
1344
|
swipeGesturePointer = null;
|
|
1345
|
+
swipeGestureFrame = 0;
|
|
1346
|
+
swipeGesturePendingStep = null;
|
|
1337
1347
|
swipeGestureListenersActive = false;
|
|
1338
1348
|
skipNextHistoryBackTransition = false;
|
|
1339
1349
|
swipeBackDepth = 0;
|
|
@@ -1376,6 +1386,7 @@ var init_cap_router_outlet = __esm({
|
|
|
1376
1386
|
this.style.width = "100%";
|
|
1377
1387
|
this.style.height = "100%";
|
|
1378
1388
|
this.style.overflow = "hidden";
|
|
1389
|
+
this.style.overscrollBehaviorX = "contain";
|
|
1379
1390
|
this.lastNavigationHref = this.getCurrentNavigationHref();
|
|
1380
1391
|
this.lastNavigationPosition = this.getCurrentNavigationPosition();
|
|
1381
1392
|
this.ownerDocument.defaultView?.addEventListener("popstate", this.handleHistoryPopState);
|
|
@@ -1683,6 +1694,10 @@ var init_cap_router_outlet = __esm({
|
|
|
1683
1694
|
this.removeEventListener("pointerup", this.handleSwipeGesturePointerEnd);
|
|
1684
1695
|
this.removeEventListener("pointercancel", this.handleSwipeGesturePointerCancel);
|
|
1685
1696
|
this.swipeGestureListenersActive = false;
|
|
1697
|
+
this.clearQueuedSwipeGestureStep();
|
|
1698
|
+
if (this.swipeGesturePointer?.transitionStarted) {
|
|
1699
|
+
this.controller.cancelInteractiveBack();
|
|
1700
|
+
}
|
|
1686
1701
|
this.swipeGesturePointer = null;
|
|
1687
1702
|
}
|
|
1688
1703
|
isSwipeGestureEnabled() {
|
|
@@ -1875,12 +1890,14 @@ var init_cap_router_outlet = __esm({
|
|
|
1875
1890
|
if (!this.canStartSwipeGesture(event)) {
|
|
1876
1891
|
return;
|
|
1877
1892
|
}
|
|
1893
|
+
const width = Math.max(this.getBoundingClientRect().width, 1);
|
|
1878
1894
|
this.swipeGesturePointer = {
|
|
1879
1895
|
pointerId: event.pointerId,
|
|
1880
1896
|
startX: event.clientX,
|
|
1881
1897
|
startY: event.clientY,
|
|
1882
1898
|
currentX: event.clientX,
|
|
1883
1899
|
currentY: event.clientY,
|
|
1900
|
+
width,
|
|
1884
1901
|
startTime: performance.now(),
|
|
1885
1902
|
dragging: false,
|
|
1886
1903
|
transitionStarted: false
|
|
@@ -1927,8 +1944,7 @@ var init_cap_router_outlet = __esm({
|
|
|
1927
1944
|
return;
|
|
1928
1945
|
}
|
|
1929
1946
|
if (event.cancelable) event.preventDefault();
|
|
1930
|
-
|
|
1931
|
-
this.controller.stepInteractiveBack(deltaX / width);
|
|
1947
|
+
this.queueSwipeGestureStep(deltaX / pointer.width);
|
|
1932
1948
|
}
|
|
1933
1949
|
};
|
|
1934
1950
|
handleSwipeGesturePointerEnd = (event) => {
|
|
@@ -1941,12 +1957,17 @@ var init_cap_router_outlet = __esm({
|
|
|
1941
1957
|
const deltaX = this.getSwipeGestureDeltaX(pointer);
|
|
1942
1958
|
const elapsed = Math.max(performance.now() - pointer.startTime, 1);
|
|
1943
1959
|
const velocityX = deltaX / elapsed;
|
|
1944
|
-
const width =
|
|
1960
|
+
const width = pointer.width;
|
|
1945
1961
|
const step = deltaX / width;
|
|
1946
1962
|
const shouldCommit = pointer.dragging && pointer.transitionStarted && velocityX >= 0 && (velocityX > this.swipeGestureMinimumVelocity || deltaX > width / 2);
|
|
1947
1963
|
const missing = shouldCommit ? 1 - step : step;
|
|
1948
1964
|
const missingDistance = Math.max(missing, 0) * width;
|
|
1949
1965
|
const releaseDuration = missingDistance > 5 && Math.abs(velocityX) > 0 ? Math.min(missingDistance / Math.abs(velocityX), 540) : 0;
|
|
1966
|
+
if (pointer.transitionStarted) {
|
|
1967
|
+
this.flushQueuedSwipeGestureStep();
|
|
1968
|
+
} else {
|
|
1969
|
+
this.clearQueuedSwipeGestureStep();
|
|
1970
|
+
}
|
|
1950
1971
|
this.releaseSwipeGesturePointer(event.pointerId);
|
|
1951
1972
|
void this.finishSwipeGestureBack(shouldCommit, releaseDuration);
|
|
1952
1973
|
};
|
|
@@ -1954,6 +1975,7 @@ var init_cap_router_outlet = __esm({
|
|
|
1954
1975
|
this.cancelSwipeGesture(event.pointerId);
|
|
1955
1976
|
};
|
|
1956
1977
|
cancelSwipeGesturePointer(pointerId) {
|
|
1978
|
+
this.clearQueuedSwipeGestureStep();
|
|
1957
1979
|
this.releaseSwipeGesturePointer(pointerId);
|
|
1958
1980
|
}
|
|
1959
1981
|
releaseSwipeGesturePointer(pointerId) {
|
|
@@ -1972,10 +1994,44 @@ var init_cap_router_outlet = __esm({
|
|
|
1972
1994
|
return;
|
|
1973
1995
|
}
|
|
1974
1996
|
this.releaseSwipeGesturePointer(pointerId);
|
|
1997
|
+
this.clearQueuedSwipeGestureStep();
|
|
1975
1998
|
if (pointer.transitionStarted) {
|
|
1976
1999
|
void this.finishSwipeGestureBack(false, 0);
|
|
1977
2000
|
}
|
|
1978
2001
|
}
|
|
2002
|
+
queueSwipeGestureStep(step) {
|
|
2003
|
+
this.swipeGesturePendingStep = step;
|
|
2004
|
+
if (this.swipeGestureFrame !== 0) {
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
const win = this.ownerDocument.defaultView;
|
|
2008
|
+
if (!win) {
|
|
2009
|
+
this.flushQueuedSwipeGestureStep();
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
this.swipeGestureFrame = win.requestAnimationFrame(() => {
|
|
2013
|
+
this.swipeGestureFrame = 0;
|
|
2014
|
+
this.flushQueuedSwipeGestureStep();
|
|
2015
|
+
});
|
|
2016
|
+
}
|
|
2017
|
+
flushQueuedSwipeGestureStep() {
|
|
2018
|
+
const step = this.swipeGesturePendingStep;
|
|
2019
|
+
this.swipeGesturePendingStep = null;
|
|
2020
|
+
if (this.swipeGestureFrame !== 0) {
|
|
2021
|
+
this.ownerDocument.defaultView?.cancelAnimationFrame(this.swipeGestureFrame);
|
|
2022
|
+
this.swipeGestureFrame = 0;
|
|
2023
|
+
}
|
|
2024
|
+
if (step !== null) {
|
|
2025
|
+
this.controller.stepInteractiveBack(step);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
clearQueuedSwipeGestureStep() {
|
|
2029
|
+
if (this.swipeGestureFrame !== 0) {
|
|
2030
|
+
this.ownerDocument.defaultView?.cancelAnimationFrame(this.swipeGestureFrame);
|
|
2031
|
+
this.swipeGestureFrame = 0;
|
|
2032
|
+
}
|
|
2033
|
+
this.swipeGesturePendingStep = null;
|
|
2034
|
+
}
|
|
1979
2035
|
async finishSwipeGestureBack(shouldComplete, releaseDuration) {
|
|
1980
2036
|
const canComplete = shouldComplete && this.getSwipeBackDestination() !== null;
|
|
1981
2037
|
const shouldUseHistory = canComplete && typeof window !== "undefined" && window.history.length > 1;
|