Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UX fixes for mobile and chromium #53

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/page/post_view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::pin::pin;
use candid::Principal;
use futures::StreamExt;
use leptos::*;
use leptos_icons::*;
use leptos_router::*;

use crate::{
Expand Down Expand Up @@ -89,6 +90,17 @@ pub fn ScrollingView() -> impl IntoView {
}
/>

<Show when=muted>
<div
class="fixed top-1/2 left-1/2 cursor-pointer"
on:click=move |_| muted.set(false)
>
<Icon
class="text-white/80 animate-ping text-4xl"
icon=icondata::BiVolumeMuteSolid
/>
</div>
</Show>
</div>
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/page/post_view/video_loader.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::canister::utils::{bg_url, mp4_url};
use leptos::{html::Video, *};
use leptos_icons::*;
use leptos_use::{use_intersection_observer_with_options, UseIntersectionObserverOptions};
use leptos_use::{
use_document, use_intersection_observer_with_options, UseIntersectionObserverOptions,
};

use super::PostViewCtx;

Expand Down Expand Up @@ -39,7 +40,7 @@ pub fn VideoView(idx: usize, muted: RwSignal<bool>) -> impl IntoView {
move |entry, _| {
let Some(visible) = entry
.into_iter()
.find(|entry| entry.is_intersecting() && entry.intersection_ratio() == 1.0)
.find(|entry| entry.is_intersecting() && entry.intersection_ratio() >= 0.8)
else {
return;
};
Expand All @@ -57,7 +58,9 @@ pub fn VideoView(idx: usize, muted: RwSignal<bool>) -> impl IntoView {
}
current_idx.set(idx);
},
UseIntersectionObserverOptions::default().thresholds(vec![1.0]),
UseIntersectionObserverOptions::default()
.thresholds(vec![1.0])
.root(use_document().as_ref().and_then(|d| d.body())),
);

// Handles autoplay
Expand Down Expand Up @@ -96,10 +99,5 @@ pub fn VideoView(idx: usize, muted: RwSignal<bool>) -> impl IntoView {
muted
preload="auto"
></video>
<Show when=move || muted() && current_idx() == idx>
<div class="fixed top-1/2 left-1/2 cursor-pointer" on:click=move |_| muted.set(false)>
<Icon class="text-white/80 animate-ping text-4xl" icon=icondata::BiVolumeMuteSolid/>
</div>
</Show>
}
}
Loading