Compare commits

...

2 commits

Author SHA1 Message Date
thislight
8e8554331b
StackedRouter: increase swipe to back area
All checks were successful
/ depoly (push) Successful in 1m22s
2024-11-21 16:22:22 +08:00
thislight
df5a976ec3
UnexpectedError: adjust visual, add selectable 2024-11-21 15:58:27 +08:00
2 changed files with 67 additions and 23 deletions

View file

@ -42,6 +42,29 @@ const UnexpectedError: Component<{ error?: any }> = (props) => {
calc(var(--safe-area-inset-bottom) + 20px)
calc(var(--safe-area-inset-left) + 20px);
}
details {
max-width: 100vw;
max-width: 100dvw;
overflow: auto;
& * {
user-select: all;
}
summary {
position: sticky;
left: 0;
top: 0;
user-select: none;
}
}
.actions {
margin-top: 20px;
margin-bottom: 20px;
}
`;
return (
@ -52,8 +75,11 @@ const UnexpectedError: Component<{ error?: any }> = (props) => {
You can restart the app to see if this guy is gone. If you meet this guy
repeatly, please report to us.
</p>
<div>
<Button onClick={() => (window.location.replace("/"))}>
<div class="actions">
<Button
onClick={() => window.location.replace("/")}
variant="contained"
>
Restart App
</Button>
</div>
@ -61,7 +87,10 @@ const UnexpectedError: Component<{ error?: any }> = (props) => {
<summary>
{errorMsg.loading ? "Generating " : " "}Technical Infomation
</summary>
<pre>{errorMsg()}</pre>
<pre>
On: {window.location.href} <br />
{errorMsg()}
</pre>
</details>
</main>
);

View file

@ -294,8 +294,9 @@ const StackedRouter: Component<StackedRouterProps> = (oprops) => {
};
let reenterableAnimation: Animation | undefined;
let origX = 0,
origWidth = 0;
let origWidth = 0,
origFigX = 0,
origFigY = 0;
const resetAnimation = () => {
reenterableAnimation = undefined;
@ -307,23 +308,25 @@ const StackedRouter: Component<StackedRouterProps> = (oprops) => {
if (event.touches.length !== 1) {
return;
}
const [fig0] = event.touches;
const { x, width } = event.currentTarget.getBoundingClientRect();
if (fig0.clientX < x - 22 || fig0.clientX > x + 22) {
return;
}
origX = x;
origWidth = width;
event.preventDefault();
event.stopPropagation();
const lastFr = stack[stack.length - 1];
const createAnimation = lastFr.animateClose ?? animateClose;
reenterableAnimation = createAnimation(event.currentTarget);
reenterableAnimation.pause();
reenterableAnimation.addEventListener("finish", resetAnimation);
reenterableAnimation.addEventListener("cancel", resetAnimation);
const [fig0] = event.touches;
const { width } = event.currentTarget.getBoundingClientRect();
origWidth = width;
origFigX = fig0.clientX;
origFigY = fig0.clientY;
if (
fig0.clientX < -22 ||
fig0.clientX > 22 ||
fig0.clientX < window.innerWidth - 22 ||
fig0.clientX > window.innerWidth + 22
) {
return;
}
// Prevent the default swipe to back/forward on iOS
event.preventDefault();
};
const onDialogTouchMove = (
@ -336,13 +339,25 @@ const StackedRouter: Component<StackedRouterProps> = (oprops) => {
}
}
if (!reenterableAnimation) return;
const [fig0] = event.touches;
const ofsX = fig0.clientX - origFigX;
if (!reenterableAnimation) {
if (!(ofsX > 22) || !(Math.abs(fig0.clientY - origFigY) < 44)) {
return;
}
const lastFr = stack[stack.length - 1];
const createAnimation = lastFr.animateClose ?? animateClose;
reenterableAnimation = createAnimation(event.currentTarget);
reenterableAnimation.pause();
reenterableAnimation.addEventListener("finish", resetAnimation);
reenterableAnimation.addEventListener("cancel", resetAnimation);
}
event.preventDefault();
event.stopPropagation();
const [fig0] = event.touches;
const ofsX = fig0.clientX - origX;
const pc = ofsX / origWidth / window.devicePixelRatio;
const { activeDuration, delay } =