Skip to content

Commit

Permalink
fix: fix remove unnecessary variables
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghong1125 committed Apr 2, 2022
1 parent 179ca06 commit ca01cbf
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/components/Sticky/src/Sticky.vue
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
</script>
Expand All @@ -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
}"
Expand Down

0 comments on commit ca01cbf

Please sign in to comment.