当前位置:网站首页>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
边栏推荐
- After inventing anti-virus software, he chose to be a top-notch gangster
- 22 years of a doctor in Huawei
- 26岁,0基础转行软件测试,从月薪3k到16k,我整理的超全学习指南
- 一键式文件共享软件Jirafeau
- This time, I will talk about technology and life
- Datakit acts as an API server for local data acquisition
- Reading notes on how to connect the network - Web server request and response (V)
- The explain function of the DALEX package of R language generates a machine learning model interpreter and predict for the specified classification prediction_ The parts function analyzes the contribu
- Automatic reply of wechat bulletin number intelligent reply with Turing robot
- 一文2500字手把手教你使用jmeter进行分布式压力测试【保姆级教程】
猜你喜欢

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

数论-整除分块

Mysql入库不了表情符号怎么办

每日刷题记录 (八)

夏日彩虹来下饭

ASP利用Panel实现简易注册页面

IFLYTEK AI learning machine summer new product launch AI + education depth combination to create a new height of products

联通入库|需要各地联通公司销售其产品的都需要先入总库

Reading notes on how to connect the network - LAN on the server side (4)

Divide the bonus pool of 10million + million yuan, and empower developers in the 2022 shengteng AI innovation competition
随机推荐
5分钟快速上手 pytest 测试框架
Reading notes on how to connect the network - LAN on the server side (4)
Common PostgreSQL data operation notes: time
分析安装包LNMP中的apache.sh脚本
Reflections on remote sensing image interpretation
Wechat bulletin number Turing robot realizes intelligent reply
Summary of basic concepts of moosefs
硅树脂油漆申请美国标准UL 790 Class A 合适吗?
26 years old, 0 basic career change software test, from 3K to 16K monthly salary, a super complete learning guide compiled by me
How to use the DVD entry level in taro3.*
Simple analysis of wieshark packet capturing MySQL protocol
Cout ambiguous problem
MooseFS 调优笔记
How to use filters in jfinal to monitor Druid for SQL execution?
小型图书馆项目总结
Golang operation NSQ distributed message queue
As a developer, you need to know about the codeless development platform IVX
Final training simple address book c language
铝板AS/NZS 1530.1 不燃性材料的阻燃测试
89. (cesium article) cesium aggregation diagram (custom picture)