Vue实现靠边悬浮球(PC端)

我想把退出登录的按钮做成一个悬浮球的样子,带动画的那种。

实现是这个样子:

手边没有球形图。所以用的毕设PPT扣的  校~,今年毕业,功能这里演示的为单机悬浮球注销登录

 

 

 

 

 

嗯,具体代码:

复制代码
  <div
                            :class="['meun-switch animated flex-row',uploadflag ? 'active rubberBand off' : 'leave jello']"
                            @mouseleave="uploadleave"
                            @mouseenter="uploadenter"
                            v-if="uploadShow"
                            @click.stop="logout"
                    >
                        <img :src="require('@/assets/1.png')"/>
                    </div>
复制代码

data

                uploadShow: false,
                uploadflag: true,

js方法

复制代码
  uploadenter() {
                this.uploadflag = true;
            },
            uploadleave() {
                this.uploadflag = false;

            },
            uploadanimated() {
                setTimeout(() => {
                    this.uploadShow = true;
                    setTimeout(() => {
                        this.uploadleave();
                    }, 1000);
                }, 1000);
            },
复制代码

css

复制代码
  .off{
        -webkit-animation:1s seconddiv;
        background: transparent;
    }

    @keyframes seconddiv{
        0% {transform: scale(1.4,1.4);}
        10% {transform: scale(1,1);}
        25% {transform: scale(1.2,1.2);}
        50% {transform: scale(1,1);}
        70% {transform: scale(1.2,1.2);}
        100% {transform: scale(1,1);}
    }
    .meun-switch {
        position: fixed;
        top: 90px;
        left: 0px;
        z-index: 2001;
        cursor: pointer;
        width: 150px;
        height: 150px;
        padding: 5px;
        transition: all 0.25s;

        &.leave {
            left: -65px;
        }

        &.active {
            left: 0;
        }

        &:hover {
            transform: scale(1.02);
        }

        img {
            width: 120px;
            height: 120px;
        }
    }
   
复制代码

 页面代码:

复制代码
<template>
    <div id="app">
        <transition name="el-zoom-in-center">
            <div v-show="show3">
                <div class="sidebar">
                    <!--            <card></card>-->
                    <list></list>
                    <div
                            :class="['meun-switch animated flex-row ys-float-btn',uploadflag ? 'active rubberBand off' : 'leave jello']"
                            @mouseleave="uploadleave"
                            @mouseenter="uploadenter"
                            v-if="uploadShow"
                            @click.stop="logout"
                    >
                        <img :src="require('@/assets/logo.png')"/>
                    </div>
                </div>
                <div class="main">
                    <message></message>
                    <usertext></usertext>
                </div>
            </div>
        </transition>

    </div>
</template>

<script>

    import list from '../../components/chat/list.vue'
    import message from '../../components/chat/message.vue'
    import usertext from '../../components/chat/usertext.vue'
    import screenfull from 'screenfull'

    export default {
        name: 'pageChat',
        data() {
            return {
                //默认不全屏
                isFullscreen: false,
                show3: false,
                uploadShow: false,
                uploadflag: true,
            }
        },
        created() {
         
        },
        mounted: function () {
            this.uploadanimated();
            this.$store.dispatch('connect');
            this.inintview();
        },
        methods: {
            /*注销*/
            logout () {
                    this.$confirm('此操作注销登录, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.getRequest('/logout');
                        window.sessionStorage.removeItem("user");
                        // 清除缓存
                        this.$router.replace("/");
                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消'
                        });
                    });
            },
            inintview() {
                setTimeout(() => {
                    this.show3 = true;
                }, 1000)
            },
            uploadenter() {
                this.uploadflag = true;
            },
            uploadleave() {
                this.uploadflag = false;

            },
            uploadanimated() {
                setTimeout(() => {
                    this.uploadShow = true;
                    setTimeout(() => {
                        this.uploadleave();
                    }, 1000);
                }, 1000);
            },
            click() {
                // 如果不允许进入全屏,发出不允许提示 浏览器不能全屏
                if (!screenfull.enabled) {
                    this.$message({
                        message: '浏览器不能全屏',
                        type: 'warning'
                    })
                    return false
                }
                screenfull.toggle()
                this.$message({
                    message: '全屏啦',
                    type: 'success'
                })
            }

        },
        components: {
            list,
            message,
            usertext
        }
    }
</script>

<style lang="scss" scoped>
    .off{
        -webkit-animation:1s seconddiv;
        background: transparent;
    }

    @keyframes seconddiv{
        0% {transform: scale(1.4,1.4);}
        10% {transform: scale(1,1);}
        25% {transform: scale(1.2,1.2);}
        50% {transform: scale(1,1);}
        70% {transform: scale(1.2,1.2);}
        100% {transform: scale(1,1);}
    }
    .meun-switch {
        position: fixed;
        top: 90px;
        left: 0px;
        z-index: 2001;
        cursor: pointer;
        width: 150px;
        height: 150px;
        padding: 5px;
        transition: all 0.25s;

        &.leave {
            left: -65px;
        }

        &.active {
            left: 0;
        }

        &:hover {
            transform: scale(1.02);
        }

        img {
            width: 120px;
            height: 120px;
        }
    }

    #particles-js {
        width: 100%;
        height: calc(100% - 100px);
        position: absolute;
        overflow: hidden;
    }

    #app {
        /*背景裁剪在背景边框内部*/
        background-clip: padding-box;
        /*// 边框样式*/
        border: 1px solid #eaeaea;
        /*// 边框阴影*/
        box-shadow: 0 0 25px #cac6c6;
        margin: 20px auto;
        width: 1100px;
        height: 100%;
        overflow: hidden;
        border-radius: 10px;
        overflow-x: hidden;

        .sidebar,
        .main {
            height: 100%;
        }

        .sidebar {
            float: left;
            color: #f4f4f4;
            background-color: transparent;
            width: 300px;
            height: 100%
        }

        .main {
            position: relative;
            overflow: hidden;
            background-color: transparent;
        }
    }
</style>
复制代码

 

posted @   山河已无恙  阅读(8220)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2019-05-08 spring整合Mybati时,只报空指针异常问题
点击右上角即可分享
微信分享提示