首页 > 其他分享 >vue网页滚动到一定程度出现动画效果

vue网页滚动到一定程度出现动画效果

时间:2022-11-17 11:33:07浏览次数:42  
标签:opacity 动画 vue 网页 log console currentHeight true toShow3

script代码



 data() {
        return {
            toShow3:false,
        };
    }

mounted() {
        window.addEventListener('scroll', this.handleScrollx, true);
    },
    methods: {
        handleScrollx() {
            const currentHeight = window.pageYOffset;
            // Container部分
            console.log(currentHeight);
            if (!this.toShow1 && currentHeight >= 780) {
                console.log('780显示');
                this.toShow1 = true;
            }
            // BehaviorWatch部分
            if (!this.toShow2 && currentHeight >= 1900) {
                console.log('1900显示');
                this.toShow2 = true;
            }
            // Advantage部分
            if (!this.toShow3 && currentHeight >= 3030) {
                console.log('3030显示');
                this.toShow3 = true;
            }
        }
        
    }

css代码

  .txt {
          // 当网页滚动到一定高度文字显现的动画效果
            @keyframes textAnimation {
                0% {
                    opacity: 0;
                }
                25% {
                    opacity: 0.5;
                }
                50% {
                    opacity: 0.8;
                }
                100% {
                    transform: translateY(-10%);
                    opacity: 1;
                }
            }

        .text1 {
            font-weight: bold;
            color: #4e4e4e;
            font-size: 48px;
            // opacity: 0;
            animation: textAnimation 2s ease-out  forwards;
        }

html代码

<div class="txt" >
            <div class="text1" v-show="toShow3">强劲带机量</div>
            <div class="text1" style="margin-bottom: 50px" v-show="toShow3">多人上网不卡顿</div>
            <div class="text2" v-show="toShow3">AX2 Pro采用OFDMA+MU-MIMO技术,实现多个用户数据同时传输,让多用户使用网</div>
            <div class="text2" v-show="toShow3">络场景下的传输速率延时更低、效率更高,满足多人同时畅快上网需求。</div>
        </div>

  

标签:opacity,动画,vue,网页,log,console,currentHeight,true,toShow3
From: https://www.cnblogs.com/hs20011205/p/16898891.html

相关文章

  • Vue props配置
    1、props配置项props的作用是让组件接收外部传过来的数据(接收参数)2、组件传参向组件Student传入参数:name,sex,age<!--第一种方式:直接写参数名=xxx,传入的是字符串形式-......
  • WPF添加GIF动画
    一:XamlAnimatedGifxmlns:gif="https://github.com/XamlAnimatedGif/XamlAnimatedGif"<Imagegif:AnimationBehavior.SourceUri="..\Images\startup.gif"gif:AnimationBe......
  • vue纯前端导入excel,获取excel的表格数据渲染el-table并纯前端分页实现方法
    因为项目开发的过程中不是所有的表格数据由后台处理返回,因为有些数据不需要在数据库落地,只做前端页面展示并且获取表格的数据上传即可,所以需要前端纯处理excel的数据。第......
  • Vue ref属性
    ref属性1.被用来给元素或子组件注册引用信息(id的替代者)2.应用在html标签上获取的是真实DOM元素,应用在组件标签上是组件实例对象(vc)3.使用方式:  1.打标识:<h1re......
  • vue3的<setup script>中使用異步函數
    由於vue3的setup一般情況下不允許為async,如果要將setup變成async,則要引入異步組件 <Suspense> <template#default> <SwitchMaintenanceUpdate/> </template> </S......
  • Vue 中 filter 过滤器的使用
    一、Filter过滤器,将数据进行添油加醋的操作。过滤器分为两种:1、组件内的过滤器(组件内有效)2、全过滤器(所以组件共享)使用前首先注册过滤器,然后再使用。全局过......
  • vue 使用ant design vue组件实现表格操作
    vue使用antdesignvue组件实现点击表格数据弹窗写在columns数组的对象里面customRender:(text,record,index)=>{if(index===this.list.length-1)......
  • vue2中请求函数防抖处理
    ......
  • Vue和Vue3在VS中的插件
     Vue的插件vetur vetur和Vue3插件VuelanguageFeature冲突,只能用一个   Vue3的插件volarVuelanguageFeature和Vue插件Vetur冲突,只能用一个 ......
  • Vue3(Mitt)
     Vue3+vite+Ts+pinia+实战+源码+全栈_哔哩哔哩_bilibili视频教程在vue3中$on,$off和$once实例方法已被移除,组件实例不再实现事件触发接口,因此大家熟悉的E......