Skip to content

Commit a65616a

Browse files
authored
chore: visibility rework (#129)
1 parent d652378 commit a65616a

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

apps/storefront-telegram/app/components/UserPointsCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<template>
22
<div class="relative w-full h-auto aspect-3/2 perspective-normal motion-preset-slide-down">
33
<div
4-
class="absolute inset-0 bg-primary rounded-lg"
4+
class="absolute inset-0 bg-primary rounded-lg transition duration-200"
55
:style="{
66
transform: `rotateX(${x * 5}deg) rotateY(${y * 5}deg)`,
77
}"
88
/>
99

1010
<div
11-
class="z-10 w-full h-full p-4 flex flex-col justify-between tg-text-button"
11+
class="z-10 w-full h-full p-4 flex flex-col justify-between transition duration-200 tg-text-button"
1212
:style="{
1313
transform: `rotateX(${x * 3}deg) rotateY(${y * 3}deg)`,
1414
}"

apps/storefront-telegram/app/components/catalog/CategoryBlock.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<template>
22
<div
3-
v-element-visibility="[
4-
(isVisible) => (isVisible && category?.slug) ? visibleCategory = category.slug : null,
5-
observerOptions,
6-
]"
3+
ref="target"
74
class="flex flex-col gap-3 mb-10"
85
>
9-
<h2 :id="category?.slug" class="scroll-mt-28 text-2xl/5 font-semibold tracking-tight">
6+
<h2 :id="category?.slug" class="scroll-mt-32 text-2xl/5 font-semibold tracking-tight">
107
{{ category?.name }}
118
</h2>
129

@@ -22,14 +19,21 @@
2219
</template>
2320

2421
<script setup lang="ts">
25-
import { vElementVisibility } from '@vueuse/components'
26-
2722
const { categoryId } = defineProps<{
2823
categoryId: string
2924
}>()
3025
3126
const { visibleCategory, observerOptions } = useCatalog()
3227
28+
const target = useTemplateRef<HTMLDivElement>('target')
29+
const targetIsVisible = useElementVisibility(target, observerOptions)
30+
31+
watch(targetIsVisible, (isVisible) => {
32+
if (isVisible && category?.slug) {
33+
visibleCategory.value = category.slug
34+
}
35+
})
36+
3337
const menuStore = useMenuStore()
3438
const category = menuStore.menu?.categories.find((c) => c.id === categoryId)
3539
const products = category?.products.filter((p) => p.isAvailableForPurchase && p.variants.length)

apps/storefront-telegram/app/composables/useCatalog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function _useCatalog() {
22
const visibleCategory = ref<string | null>(null)
33

4-
const observerOptions = { rootMargin: '0px 0px 0px 0px' }
4+
const observerOptions = { rootMargin: '0px 0px -150px 0px' }
55

66
const scrollToCategory = useDebounceFn(() => {
77
const category = window.document.getElementById(`to-${visibleCategory.value}`)

apps/storefront-telegram/app/utils/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export async function init(options: {
9292

9393
// Gyroscope
9494
postEvent('web_app_start_gyroscope', {
95-
refresh_rate: 500,
95+
refresh_rate: 80,
9696
})
9797

9898
if (mountViewport.isAvailable()) {

0 commit comments

Comments
 (0)