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