Compare commits

..

3 commits

Author SHA1 Message Date
thislight
4d3f5c911b
StackedRouter: try to fix the swipe to back
All checks were successful
/ depoly (push) Successful in 1m21s
2024-11-18 23:59:14 +08:00
thislight
e124d3e5b8
MediaAttachmentGrid: indicates loading 2024-11-18 23:31:47 +08:00
thislight
ed53f24ede
PreviewCard: indicates loading 2024-11-18 23:29:44 +08:00
4 changed files with 20 additions and 9 deletions

View file

@ -306,10 +306,7 @@ const StackedRouter: Component<StackedRouterProps> = (oprops) => {
} }
const [fig0] = event.touches; const [fig0] = event.touches;
const { x, width } = event.currentTarget.getBoundingClientRect(); const { x, width } = event.currentTarget.getBoundingClientRect();
if ( if (fig0.clientX < x - 22 || fig0.clientX > x + 22) {
fig0.clientX - fig0.radiusX < x - 22 ||
fig0.clientX + fig0.radiusX > x + 22
) {
return; return;
} }
origX = x; origX = x;
@ -416,10 +413,10 @@ const StackedRouter: Component<StackedRouterProps> = (oprops) => {
class="StackedPage" class="StackedPage"
onCancel={[popFrame, 1]} onCancel={[popFrame, 1]}
onClick={[onDialogClick, popFrame]} onClick={[onDialogClick, popFrame]}
onTouchStart={onDialogTouchStart} on:touchstart={onDialogTouchStart}
onTouchMove={onDialogTouchMove} on:touchmove={onDialogTouchMove}
onTouchEnd={onDialogTouchEnd} on:touchend={onDialogTouchEnd}
onTouchCancel={onDialogTouchCancel} on:touchcancel={onDialogTouchCancel}
id={frame().rootId} id={frame().rootId}
> >
<StaticRouter url={frame().path} {...oprops} /> <StaticRouter url={frame().path} {...oprops} />

View file

@ -12,7 +12,7 @@
min-width: 40px; min-width: 40px;
object-fit: contain; object-fit: contain;
max-width: 100%; max-width: 100%;
background-color: var(--tutu-color-surface-d); background-color: var(--media-color-accent, var(--tutu-color-surface-d));
border-radius: 2px; border-radius: 2px;
border: 1px solid var(--tutu-color-surface-d); border: 1px solid var(--tutu-color-surface-d);
transition: outline-width 60ms var(--tutu-anim-curve-std), border-color 60ms var(--tutu-anim-curve-std); transition: outline-width 60ms var(--tutu-anim-curve-std), border-color 60ms var(--tutu-anim-curve-std);

View file

@ -19,6 +19,10 @@
background-color: var(--tutu-color-surface); background-color: var(--tutu-color-surface);
max-width: 100%; max-width: 100%;
height: auto; height: auto;
&.loaded {
background-color: #eeeeee;
}
} }
&:hover, &:hover,

View file

@ -5,6 +5,14 @@ import { Title, Body1 } from "../../material/typography";
import { averageColorHex } from "../../platform/blurhash"; import { averageColorHex } from "../../platform/blurhash";
import "./PreviewCard.css"; import "./PreviewCard.css";
function onResetImg(event: Event & { currentTarget: HTMLImageElement }) {
event.currentTarget.classList.remove("loaded");
}
function onImgLoaded(event: Event & { currentTarget: HTMLImageElement }) {
event.currentTarget.classList.add("loaded");
}
export function PreviewCard(props: { export function PreviewCard(props: {
src: mastodon.v1.PreviewCard; src: mastodon.v1.PreviewCard;
alwaysCompact?: boolean; alwaysCompact?: boolean;
@ -81,6 +89,8 @@ export function PreviewCard(props: {
> >
<Show when={props.src.image}> <Show when={props.src.image}>
<img <img
onLoadStart={onResetImg}
onLoad={onImgLoaded}
crossOrigin="anonymous" crossOrigin="anonymous"
src={props.src.image!} src={props.src.image!}
width={props.src.width || undefined} width={props.src.width || undefined}