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

fix(#865): BackgroundVideo.astro not playing when changing combat #866

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
233f5b9
fix(BackgroundVideo): not playing when changing combat
AlejandroSuero Apr 5, 2024
26e698c
fix: moved video into function and removed `removeEventListener()`
AlejandroSuero Apr 5, 2024
928b625
feat: added `playsinline` for iOS support
AlejandroSuero Apr 5, 2024
b81e533
fix: removed autoplay
AlejandroSuero Apr 5, 2024
ad975f1
Feature/fix background video playing (#1)
yurigo Apr 5, 2024
1f1c07c
feat: added `isFirefox` check for view transitions
AlejandroSuero Apr 5, 2024
db4e96e
fix: added autoplay
AlejandroSuero Apr 5, 2024
8d1b2ba
fix: modified according to @yurigo's changes
AlejandroSuero Apr 6, 2024
43257f0
feat: added `isFirefox` check after testing it
AlejandroSuero Apr 6, 2024
acf89fe
Merge branch 'main' into feature/fix-background-video-playing
midudev Apr 12, 2024
75272c9
Merge branch 'main' into feature/fix-background-video-playing
midudev Apr 12, 2024
96060e9
fix: removed firefox detection code
AlejandroSuero Apr 12, 2024
e4232a9
fix: added `transition:name`
AlejandroSuero Apr 12, 2024
b1143c4
Merge branch 'main' into feature/fix-background-video-playing
AlejandroSuero Apr 23, 2024
077c5c2
fix(BackgroundVideo): modified to use `@/lib/dom-selector`
AlejandroSuero May 1, 2024
2f5ab0d
Merge branch 'main' into feature/fix-background-video-playing
AlejandroSuero May 1, 2024
c251dec
Merge branch 'main' into feature/fix-background-video-playing
midudev May 14, 2024
73964a3
Merge branch 'main' into feature/fix-background-video-playing
AlejandroSuero May 14, 2024
4b3cae1
Merge branch 'midudev:main' into feature/fix-background-video-playing
AlejandroSuero May 16, 2024
3c7722d
Merge branch 'main' into feature/fix-background-video-playing
midudev May 17, 2024
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
3 changes: 3 additions & 0 deletions src/lib/browser.ts
AlejandroSuero marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const isFirefox = (): boolean => {
return typeof InstallTrigger !== "undefined"
}
31 changes: 23 additions & 8 deletions src/pages/combates/[id].astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Image } from "astro:assets"
import BackgroundVideo from "@/components/Combates/BackgroundVideo.astro"
import { COMBATS } from "@/consts/combats"
import Layout from "@/layouts/Layout.astro"
import { isFirefox } from "@/lib/browser"
import CombatFeatures from "@/sections/CombatFeatures.astro"

const getCombatById = (id: string) => {
Expand Down Expand Up @@ -47,14 +48,28 @@ const [imageWidth, imageHeight] = combatData.titleSize
<BackgroundVideo id={id} />
<main class="pointer-events-none md:-mt-12">
<div class="relative flex h-[60vh] w-full items-center justify-center md:h-[76vh]">
<Image
width={imageWidth}
height={imageHeight}
loading={"eager"}
class="inset-0 h-auto max-h-96 w-full max-w-80 scale-100 object-contain sm:scale-110 lg:max-w-3xl"
src={`https://cdn.lavelada.dev/matches/title-${id}.webp`}
alt={`Fotografía del combate entre ${boxerNames.join(", ")}`}
/>
{
isFirefox() ? (
<Image
width={imageWidth}
height={imageHeight}
loading={"eager"}
class="inset-0 h-auto max-h-96 w-full max-w-80 scale-100 object-contain sm:scale-110 lg:max-w-3xl"
src={`https://cdn.lavelada.dev/matches/title-${id}.webp`}
alt={`Fotografía del combate entre ${boxerNames.join(", ")}`}
/>
) : (
<Image
width={imageWidth}
height={imageHeight}
transition:name={`title-image-${id}`}
loading={"eager"}
class="inset-0 h-auto max-h-96 w-full max-w-80 scale-100 object-contain sm:scale-110 lg:max-w-3xl"
src={`https://cdn.lavelada.dev/matches/title-${id}.webp`}
alt={`Fotografía del combate entre ${boxerNames.join(", ")}`}
/>
)
}
</div>
<div class="pointer-events-auto">
{combatData.boxers.length <= 4 && <CombatFeatures boxerIds={combatData.boxers} />}
Expand Down
45 changes: 32 additions & 13 deletions src/pages/combates/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Image } from "astro:assets"
import Typography from "@/components/Typography.astro"
import { COMBATS, REY_DE_LA_PISTA_ID } from "@/consts/combats"
import Layout from "@/layouts/Layout.astro"
import { isFirefox } from "@/lib/browser"

const getCombatById = (id: string) => {
return COMBATS.find((combat) => combat.id === id)
Expand All @@ -14,7 +15,10 @@ const getBoxerNames = (boxerIds: string[]): string[] => {
}
---

<Layout description={"Todos los combates de La Velada del Año IV"} title={"Combates - La Velada del Año IV"}>
<Layout
description={"Todos los combates de La Velada del Año IV"}
title={"Combates - La Velada del Año IV"}
>
<main class="flex min-h-screen flex-col items-center text-[#b4cd02]">
<div class="mx-auto w-full max-w-4xl p-8">
<Typography
Expand Down Expand Up @@ -54,18 +58,33 @@ const getBoxerNames = (boxerIds: string[]): string[] => {
alt={`Fotografía del combate entre ${boxerNames.join(", ")}`}
style="mask-image: linear-gradient(black 90%, transparent 100%);"
/>
<Image
width={combatData.titleSize[0]}
height={combatData.titleSize[1]}
loading={index < 2 ? "eager" : "lazy"}
class:list={[
"group-hover:saturate-15 absolute left-1/2 h-auto max-h-[15rem] w-auto -translate-x-1/2 transform-gpu transition-all duration-300 ease-in-out group-hover:scale-75",
{ "top-10 z-10 md:z-20": isKingOfTheHill },
{ "-bottom-20 z-20": !isKingOfTheHill },
]}
src={`https://cdn.lavelada.dev/matches/title-${combat.id}.webp`}
alt={`Fotografía del combate entre ${boxerNames.join(", ")}`}
/>
{isFirefox() ? (
<Image
width={combatData.titleSize[0]}
height={combatData.titleSize[1]}
loading={index < 2 ? "eager" : "lazy"}
class:list={[
"group-hover:saturate-15 absolute left-1/2 h-auto max-h-[15rem] w-auto -translate-x-1/2 transform-gpu transition-all duration-300 ease-in-out group-hover:scale-75",
{ "top-10 z-10 md:z-20": isKingOfTheHill },
{ "-bottom-20 z-20": !isKingOfTheHill },
]}
src={`https://cdn.lavelada.dev/matches/title-${combat.id}.webp`}
alt={`Fotografía del combate entre ${boxerNames.join(", ")}`}
/>
) : (
<Image
width={combatData.titleSize[0]}
AlejandroSuero marked this conversation as resolved.
Show resolved Hide resolved
height={combatData.titleSize[1]}
loading={index < 2 ? "eager" : "lazy"}
class:list={[
"group-hover:saturate-15 absolute left-1/2 h-auto max-h-[15rem] w-auto -translate-x-1/2 transform-gpu transition-all duration-300 ease-in-out group-hover:scale-75",
{ "top-10 z-10 md:z-20": isKingOfTheHill },
{ "-bottom-20 z-20": !isKingOfTheHill },
]}
src={`https://cdn.lavelada.dev/matches/title-${combat.id}.webp`}
alt={`Fotografía del combate entre ${boxerNames.join(", ")}`}
/>
)}
<div class="gradient-box absolute bottom-0 z-0 block h-2/5 w-full opacity-25 transition-opacity duration-300 ease-in-out group-hover:brightness-50 group-hover:filter" />
</a>
</li>
Expand Down