-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(animatin): imported
gsap
and implemented some animations
- Loading branch information
1 parent
b75dbae
commit 92788d4
Showing
4 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<template> | ||
<span ref="main" | ||
class="gl-sub-menu" | ||
tabindex="4" | ||
@click="toggleLangMenu()" | ||
> | ||
<slot name="content"></slot> | ||
<ul id="items" style="transform-origin: top;"> | ||
<slot name="items" /> | ||
</ul> | ||
</span> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import gsap from 'gsap'; | ||
import { onMounted, reactive, ref } from 'vue'; | ||
const main = ref(); | ||
const visible = reactive({ | ||
value: true | ||
}); | ||
let ctx; | ||
const renderMenu = (visible: boolean, ul) => { | ||
if (visible) { | ||
gsap.set(ul, { | ||
scaleY: 1, | ||
opacity: 1 | ||
}) | ||
} else { | ||
gsap.to(ul, { | ||
scaleY: 0, | ||
opacity: 0, | ||
duration: .3, | ||
ease: 'power4.out' | ||
}) | ||
} | ||
} | ||
const toggleLangMenu = () => { | ||
gsap.context(self => { | ||
const ul = self.selector?.('ul') | ||
renderMenu(visible.value, ul) | ||
}, main.value) | ||
visible.value = !visible.value; | ||
} | ||
</script> | ||
|
||
<style lang="less"> | ||
@primary-color: #5352ed; | ||
@font-color: darken(@primary-color, 20%); | ||
.gl-sub-menu { | ||
position: relative; | ||
display: inline-blocks; | ||
cursor: pointer; | ||
&>ul { | ||
display: block; | ||
position: absolute; | ||
top: calc(100%); | ||
right: 0; | ||
min-width: 100px; | ||
padding: 10px; | ||
border: 1px solid white; | ||
border-radius: 10px; | ||
background: rgba(255, 255, 255, .8); | ||
color: @primary-color; | ||
&>li { | ||
padding: 5px; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
&:hover { | ||
color: @font-color; | ||
background: white; | ||
} | ||
} | ||
} | ||
&:hover ul { | ||
// display: block; | ||
} | ||
} | ||
</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