From bbd9f840b52e5c33ca9f075b660087c26dfafb78 Mon Sep 17 00:00:00 2001
From: YunYouJun
Date: Sun, 17 Apr 2022 03:27:55 +0800
Subject: [PATCH] feat: add emoji to pot animation
---
src/components.d.ts | 1 +
src/components/AnimateStuff.vue | 18 +++++++++
src/components/ChooseFood.vue | 72 +++++++++++++++++++++++++++------
src/composables/helper.ts | 13 +++---
src/pages/index.vue | 3 ++
5 files changed, 86 insertions(+), 21 deletions(-)
create mode 100644 src/components/AnimateStuff.vue
diff --git a/src/components.d.ts b/src/components.d.ts
index 4e20cf6..48c4055 100644
--- a/src/components.d.ts
+++ b/src/components.d.ts
@@ -5,6 +5,7 @@ import '@vue/runtime-core'
declare module '@vue/runtime-core' {
export interface GlobalComponents {
+ AnimateStuff: typeof import('./components/AnimateStuff.vue')['default']
BaseFooter: typeof import('./components/BaseFooter.vue')['default']
ChooseFood: typeof import('./components/ChooseFood.vue')['default']
Counter: typeof import('./components/Counter.vue')['default']
diff --git a/src/components/AnimateStuff.vue b/src/components/AnimateStuff.vue
new file mode 100644
index 0000000..206af3a
--- /dev/null
+++ b/src/components/AnimateStuff.vue
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/src/components/ChooseFood.vue b/src/components/ChooseFood.vue
index 5a46443..70eb937 100644
--- a/src/components/ChooseFood.vue
+++ b/src/components/ChooseFood.vue
@@ -1,5 +1,6 @@
+
+
+ {{ curEmoji }}
+
+
@@ -89,7 +140,7 @@ const { isVisible, show } = useInvisibleElement(recipePanel)
toggleStuff(item, 'vegetable')"
>
{{ item.emoji }}
@@ -177,11 +228,6 @@ const { isVisible, show } = useInvisibleElement(recipePanel)
大胆尝试一下,或者
换个组合?
-
-
-
- 更多囤货、水培攻略:隔离食用手册大全
-
diff --git a/src/composables/helper.ts b/src/composables/helper.ts
index 414dd8b..336fe23 100644
--- a/src/composables/helper.ts
+++ b/src/composables/helper.ts
@@ -1,6 +1,5 @@
-import { useElementBounding, useIntersectionObserver } from '@vueuse/core'
+import { useElementBounding } from '@vueuse/core'
import type { Ref } from 'vue'
-import { ref } from 'vue'
/**
* trigger show invisible element
@@ -8,16 +7,14 @@ import { ref } from 'vue'
* @returns
*/
export function useInvisibleElement(target: Ref) {
- const isVisible = ref(false)
const { top } = useElementBounding(target)
- useIntersectionObserver(target, ([{ isIntersecting }]) => {
- isVisible.value = isIntersecting
+
+ const isVisible = computed(() => {
+ return window.scrollY < top.value
})
const show = () => {
- // scroll when collapse is not visible
- if (!isVisible.value)
- window.scrollTo(0, top.value)
+ window.scrollTo(0, top.value)
}
return {
diff --git a/src/pages/index.vue b/src/pages/index.vue
index 00d3e71..3a3602a 100644
--- a/src/pages/index.vue
+++ b/src/pages/index.vue
@@ -19,6 +19,9 @@ const rStore = useRecipeStore()
+
+ 更多囤货、水培攻略:隔离食用手册大全
+