当前位置: 首页 > news >正文

合肥网站制作哪家强网络服务平台

合肥网站制作哪家强,网络服务平台,1999年怎样建立企业网站,哈尔滨学网页设计水个文 效果 要实现的思路就是,使用IntersectionObserver 检测元素是否在视口中显示,然后在通过css来进行动画载入。 1.监控元素是否视口中显示 const observer new IntersectionObserver((entries) > {entries.forEach((entry) > {if (entry.i…

水个文

效果

要实现的思路就是,使用IntersectionObserver 检测元素是否在视口中显示,然后在通过css来进行动画载入。

1.监控元素是否视口中显示

      const observer = new IntersectionObserver((entries) => {entries.forEach((entry) => {if (entry.isIntersecting) {acc.value = true}});});//监控元素observer.observe(slideInAnimation.value);

        其中 if里就是当元素显示在视口中要执行的逻辑 

        然后在调用,在里面要传入要监控元素的元素对象,这里要在onmounted里调用,注意异步

    onMounted(() => {//监控元素observer.observe(slideInAnimation.value);});

2.设置css

.box {overflow: hidden;height: 4000px;/* 为了演示效果,设置一个高度 */display: flex;justify-content: center;align-items: center;
}.slide-in-animation,
.onslide-in-animation {width: 400px;height: 200px;
}  //定义一个基础的数据,.slide-in-animation {  //这个是要载入时,将css替换即可background-color: #f00;position: relative;animation: slide-in 4s forwards; //持续时间
}@keyframes slide-in { //定义加载方式0% {visibility: hidden; //当百分0时元素不显示,从最右边加载,left: 100%;}100% { left: 0%;  //百分百时加载到最左边}
}

大概是这个个逻辑,然后通过三目运算来控制class的值

  <div class="box"><div :class="acc ? 'slide-in-animation' : 'onslide-in-animation'" ref="slideInAnimation"><img src="https://www.gm.com/assets/%E5%8D%81%E5%9B%9B%E6%9C%9F-CKW22HE9.png" alt=""style="width:400px;height:200px;"></div></div>

acc最开始是false,不显示,而当元素在视口里时,将slide-in-animation类名加入,执行动画,然后实现滑动到元素位置时元素滑动载入,这里我只是做了一个示例,通过  @keyframes 可以实现更复杂的效果

源码

<template><div class="box"><div :class="acc ? 'slide-in-animation' : 'onslide-in-animation'" ref="slideInAnimation"><img src="https://www.gm.com/assets/%E5%8D%81%E5%9B%9B%E6%9C%9F-CKW22HE9.png" alt=""style="width:400px;height:200px;"></div></div>
</template><script>
import { defineComponent, ref, onMounted } from 'vue';export default defineComponent({setup() {const slideInAnimation = ref(null);const observer = new IntersectionObserver((entries) => {entries.forEach((entry) => {if (entry.isIntersecting) {acc.value = true}});});onMounted(() => {//监控元素observer.observe(slideInAnimation.value);});const acc = ref(false)return {slideInAnimation, acc};}
});
</script><style scoped>
.box {overflow: hidden;height: 4000px;/* 为了演示效果,设置一个高度 */display: flex;justify-content: center;align-items: center;
}.slide-in-animation,
.onslide-in-animation {width: 400px;height: 200px;}.slide-in-animation {background-color: #f00;position: relative;animation: slide-in 4s forwards;
}@keyframes slide-in {0% {visibility: hidden;left: 100%;}100% {left: 0%;}
}
</style>

http://www.masaee.cn/news/71.html

相关文章:

  • 利用淘宝视频服务做视频网站站长素材官网免费
  • 怎样在网站做推广网页制作接单
  • 南京原创网站建设怎么联系百度指数功能模块有哪些
  • 投资做网易bobo一样的社区视频网站大概需要多少资金兰州seo
  • 蓝众建站_专业网站建设广告商对接平台
  • 攻击静态网站湖北网站seo
  • 拖鞋设计网站推荐查网站流量的网址
  • 郑州五合一网站建设惠州seo怎么做
  • 怎样在网上建网站做电商生意电商软文范例
  • 清华大学学生工作做网站合作seo公司
  • 做电子商城网站今天发生的重大新闻事件
  • 湖州网站集约化平台怎么做一个公司网站
  • 湖北宜昌推广seo与sem的区别和联系
  • 国内做ebay用哪个网站新乡seo外包
  • dreamweaver做网站教程seo优化外链平台
  • 澳门网站关键词优化中国联通业绩
  • 成都网站建设 川icp备数据分析软件
  • 博客自助建站软文范例大全
  • 小红书网站建设内容产品推广的渠道
  • MAC怎么做网站百度首页排名优化公司
  • 网站建设立项报告seo怎么刷排名
  • 网站建设好的搜索引擎优化搜索优化
  • wordpress __seo简单优化操作步骤
  • 做网站 大文件世界足球排名前十名
  • 哈尔滨网站建设设计网络营销的主要工作有哪些
  • 企业网站推广推广阶段西安关键词seo
  • 网站建设外包公司招聘惠州seo代理商
  • 百度怎样建立网站链接可以做产品推广的软件有哪些
  • ims2009 asp企业网站建设企业网站设计公司
  • 济南seo网站优化公司电商平台网站