-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Logo ticker updates and carousel buttons
- Loading branch information
Lindsey Zylstra
committed
Nov 14, 2024
1 parent
9ed79fc
commit c2552ff
Showing
5 changed files
with
49 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,41 @@ | ||
<script setup lang="ts"> | ||
import { useIntersectionObserver, useResizeObserver } from '@vueuse/core'; | ||
import type { BlockLogoCloudLogo } from '~/types/schema/blocks'; | ||
import type { File } from '~/types/schema'; | ||
import { Vue3Marquee } from 'vue3-marquee'; | ||
const props = defineProps<{ | ||
logos: BlockLogoCloudLogo[]; | ||
}>(); | ||
const logoArray = computed(() => { | ||
const blockLogos = unref(props.logos) ?? []; | ||
return [...blockLogos, ...blockLogos]; | ||
}); | ||
const ticker = ref<HTMLElement | null>(null); | ||
const target = ref<HTMLElement | null>(null); | ||
const tickerWidth = ref<number | null>(null); | ||
const isVisible = ref(false); | ||
useIntersectionObserver( | ||
target, | ||
([{ isIntersecting }]) => { | ||
isVisible.value = isIntersecting; | ||
}, | ||
{ | ||
threshold: 0.25, | ||
}, | ||
); | ||
const duration = computed(() => { | ||
if (tickerWidth.value) { | ||
const calculatedDuration = tickerWidth.value / 60; // 60px per second; | ||
return `${calculatedDuration * 1000}ms`; | ||
} else return '0ms'; | ||
}); | ||
// Adjust duration on resize | ||
useResizeObserver(ticker, (entries) => { | ||
tickerWidth.value = (entries[0].target as HTMLElement).offsetWidth; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div class="block-logocloud-ticker"> | ||
<div ref="target" class="marquee-wrapper"> | ||
<div | ||
ref="ticker" | ||
:class="[{ animate: isVisible }, 'marquee']" | ||
:style="{ | ||
'--marquee-duration': duration, | ||
}" | ||
> | ||
<Vue3Marquee :clone="true" :gradient="true" :gradient-color="[250, 250, 250]" gradient-length="5%"> | ||
<div class="logo-container"> | ||
<BaseDirectusImage | ||
v-for="logo in logoArray" | ||
v-for="logo in props.logos" | ||
:key="logo.id" | ||
:uuid="(logo.directus_files_id as File).id" | ||
:alt="(logo.directus_files_id as File).description ?? ''" | ||
/> | ||
<div class="logo-spacer"></div> | ||
</div> | ||
</div> | ||
</Vue3Marquee> | ||
</div> | ||
</template> | ||
<style scoped lang="scss"> | ||
.block-logocloud-ticker { | ||
position: relative; | ||
display: flex; | ||
overflow: hidden; | ||
.marquee-wrapper { | ||
position: relative; | ||
width: 100%; | ||
height: 100%; | ||
overflow: hidden; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 100 100"><defs><linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="white" stop-opacity="0"/><stop offset="20%" stop-color="white"/><stop offset="80%" stop-color="white"/><stop offset="100%" stop-color="white" stop-opacity="0"/></linearGradient></defs><rect x="0" y="0" width="100" height="100" fill="url(%23gradient)" /></svg>'); | ||
mask-repeat: no-repeat; | ||
mask-size: 100%; | ||
mask-position: center center; | ||
} | ||
.marquee { | ||
.logo-container { | ||
display: flex; | ||
gap: var(--space-14); | ||
&.animate { | ||
animation: marquee var(--marquee-duration) linear infinite; | ||
} | ||
& img { | ||
flex-shrink: 0; | ||
max-width: var(--space-48); | ||
height: var(--space-20); | ||
object-fit: contain; | ||
} | ||
} | ||
} | ||
@keyframes marquee { | ||
0% { | ||
transform: translateX(0); | ||
} | ||
100% { | ||
transform: translateX(calc(-50%)); | ||
& img { | ||
flex-shrink: 0; | ||
max-width: var(--space-48); | ||
height: var(--space-20); | ||
object-fit: contain; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.