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

有没有做视频的网站软件开发培训学校

有没有做视频的网站,软件开发培训学校,台山网站定制,做3d动画的斑马网站水个文 效果 要实现的思路就是,使用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.hrbkazy.com/news/3609.html

相关文章:

  • 南昌网站建设规划方案网推广公司
  • 网站建设工具哪个好用短视频询盘获客系统
  • 网站建设一般需要多少钱中国四大软件外包公司
  • 做外贸的网站怎么建立百度指数网页版
  • wordpress 连接信息阿拉善盟seo
  • 网站开发 行业动态什么是白帽seo
  • 设计说明万能模板300字武汉seo网络营销推广
  • 环球资源网商务网站建设目的360seo关键词优化
  • 安徽安庆网站建设公司seo公司优化
  • 虚拟交易网站开发seo优化软件哪个好
  • 做网站要运用到代码吗营销方法
  • 上海网站建设 知名觉如何推销自己的产品
  • 个人网站域名后缀seo个人优化方案案例
  • 大型集团网站建设seo优化收费
  • 怎样建设公司网站网站推广找哪家公司好
  • 打码兔怎么和网站做接口怎么策划一个营销方案
  • 中铁建设集团有限公司电话百度推广优化中心
  • 学生制作网站建设 维护百度网站链接
  • 用ih5做微网站最好的网站设计公司
  • 音视频娱乐网站开发商怎么免费注册域名
  • dedecms手机网站制作站长工具seo综合查询权重
  • 西乡城建局网站百度搜索开放平台
  • 电子商务网站建设目的上海十大营销策划公司排名
  • 对网站开发流程的认识网络运营培训班
  • 网站开发类型win10优化大师官网
  • 网站建设通知书国家卫健委:不再发布每日疫情信息
  • 制作网页改颜色网站seo关键词排名推广
  • 网站开发制作案例seo必备工具
  • 网站安全措施经典广告推广词
  • 动态网站课程和网站建设课程互联网营销模式有哪些