当前位置:网站首页>Live broadcast platform development, enter the visual area to execute animation, dynamic effects and add style class names
Live broadcast platform development, enter the visual area to execute animation, dynamic effects and add style class names
2022-06-29 22:19:00 【Yunbao network technology】
Live platform development , Enter the visual area to execute the animation 、 Dynamic effect 、 Add style class name
Add a global custom directive
import Vue from 'vue'
// register 'v-animate' When the element appears in the visual range, add the class name to trigger the dynamic style
Vue.directive('animate', {
inserted: function (el, binding) {
// Focusing on the element
binding.addClass = () => {
const {
top } = el.getBoundingClientRect()
const h = document.documentElement.clientHeight || document.body.clientHeight
if (top < h) {
if(el.className.indexOf(binding.value) == -1 ){
// It has not been bound for the first time , Add a new class name ( Be careful : There is a space in the middle of the single quotation mark below !!!)
el.className = binding.value+' '+el.className
}
if (binding.addClass) {
window.removeEventListener('scroll', binding.addClass)
}
}
}
window.addEventListener('scroll', binding.addClass,true)
binding.addClass()
},
unbind: function (el, binding) {
if (binding.addClass) {
window.removeEventListener('scroll', binding.addClass)
}
}
})
go back to html Add... To the places where dynamic effects need to be added Class name
<p class="title" v-animate="'queue-bottom'"> I'm a title that needs action </p>
Animation effect :
@keyframes bottomMoveTop{
0%{
opacity: 0;
transform: translate3d(0, 50px, 0);
}
100% {
opacity: 1;
transform: none;
}
}
.queue-bottom {
animation: bottomMoveTop .6s cubic-bezier(.5,1,.89,1);
animation-fill-mode: forwards;
}
The above is the development of live broadcasting platform , Enter the visual area to execute the animation 、 Dynamic effect 、 Add style class name , More content welcome to follow the article
边栏推荐
- jfinal中如何使用过滤器监控Druid监听SQL执行?
- 一键式文件共享软件Jirafeau
- Simple understanding of why to rewrite hashcode and equals methods at the same time
- Golang operation etcd
- The inadvertently discovered [tidb cache table] can solve the read / write hotspot problem
- Type of radar
- Summer Challenge harmonyos ark development framework arkui streamer button effect
- [force deduction 10 days SQL introduction] day7+8 calculation function
- 软件快速交付真的需要以安全为代价吗?
- Don't worry about form deformation anymore
猜你喜欢

leetcode:91. 解码方法【dfs + 记忆化】

每日刷题记录 (八)

华为云AOM 2.0版本发布

Golang operation etcd

Deep learning remote sensing data set

5-minute quick start pytest testing framework

读书郎上市背后隐忧:业绩下滑明显,市场地位较靠后,竞争力存疑

这次跟大家聊聊技术,也聊聊人生

华为7年经验的软件测试总监,给所有想转行学软件测试的同学的几个建议

How to use SMS to deliver service information to customers? The guide is here!
随机推荐
便携式4K音视频会议终端一体机带8倍数字变焦
彩涂钢板密封板申请BS 476-3如何备样?
Type of radar
DevCloud加持下的青软,让教育“智”上云端
如果我在珠海,到哪里开户比较好?究竟网上开户是否安全么?
2022 openvino DevCon unveils secrets! Intel and many partners deepen the construction of developer ecology and release the innovation potential of AI industry
Small library project summary
The correct method for Navicat to connect to mysql8.0 (valid for personal testing)
CLI tool foundation of ros2 robot f1tenth
Numpy array creation
MooseFS基本概念总结
新手必须知道的 Kubernetes 架构
软件快速交付真的需要以安全为代价吗?
[cloud native] use of Nacos taskmanager task management
ASP.NET 跨页面提交(Button控件页面重定向)
一文2500字手把手教你使用jmeter进行分布式压力测试【保姆级教程】
Golang operation etcd
IFLYTEK AI learning machine summer new product launch AI + education depth combination to create a new height of products
交友平台小程序制作开发代码分享
Use of golang gopsutil Library: process and system resource monitoring (CPU, memory, disk, etc.)