From ca01cbfd98b63a0d76190fe8d43097fdc9df74e6 Mon Sep 17 00:00:00 2001 From: huanghong Date: Sat, 2 Apr 2022 15:08:17 +0800 Subject: [PATCH] fix: fix remove unnecessary variables --- src/components/Sticky/src/Sticky.vue | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/Sticky/src/Sticky.vue b/src/components/Sticky/src/Sticky.vue index 4e4a3cf..6906fbc 100644 --- a/src/components/Sticky/src/Sticky.vue +++ b/src/components/Sticky/src/Sticky.vue @@ -19,7 +19,6 @@ const props = defineProps({ default: 'top' } }) -const active = ref(false) const width = ref('auto' as string) const height = ref('auto' as string) const isSticky = ref(false) @@ -108,18 +107,16 @@ const handleReize = () => { } } const sticky = () => { - if (active.value) { + if (isSticky.value) { return } - active.value = true isSticky.value = true } const reset = () => { - if (!active.value) { + if (!isSticky.value) { return } width.value = 'auto' - active.value = false isSticky.value = false } @@ -131,7 +128,7 @@ const reset = () => { top: position === 'top' ? offset + 'px' : '', bottom: position !== 'top' ? offset + 'px' : '', zIndex: zIndex, - position: active ? 'fixed' : 'static', + position: isSticky ? 'fixed' : 'static', width: width, height: height }"