当前位置:网站首页>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
边栏推荐
- cout 不明确问题
- Information available from radar echo
- [multithreading] how to implement timer by yourself
- Summer Challenge harmonyos ark development framework arkui streamer button effect
- Reflections on remote sensing image interpretation
- Cout ambiguous problem
- jfinal中如何使用过滤器监控Druid监听SQL执行?
- 如果我在珠海,到哪里开户比较好?究竟网上开户是否安全么?
- 小型圖書館項目總結
- A mysql IBD file is too large processing record
猜你喜欢

American tunneling ASTM E84 surface flame retardant test

Detailed explanation of MySQL and mvcc and the difference between RC and RR for snapshot reading

细说GaussDB(DWS)复杂多样的资源负载管理手段

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

5分钟快速上手 pytest 测试框架

Huawei cloud AOM version 2.0 release

便携式4K音视频会议终端一体机带8倍数字变焦

This time, I will talk about technology and life

Motianlun "high availability architecture" dry goods document sharing (including 124 Oracle, MySQL and PG materials)

ASP.NET 跨页面提交(Button控件页面重定向)
随机推荐
If I am in Zhuhai, where can I open an account? Is it safe to open an account online?
Analysis of typical remote sensing tasks
American tunneling ASTM E84 surface flame retardant test
Three development trends of enterprise application viewed from the third technological revolution
IFLYTEK AI learning machine summer new product launch AI + education depth combination to create a new height of products
泰山OFFICE技术讲座:一行中所有元素高度相同
软件快速交付真的需要以安全为代价吗?
阶段性总结与思考
State management uses session to restrict page access. Only login can verify sessionlogin Aspx can access session aspx
Taro applet enables wxml code compression
89. (cesium article) cesium aggregation diagram (custom picture)
5分钟快速上手 pytest 测试框架
MooseFS基本概念总结
从检查点恢复后读取不到mysql的数据有那位兄台知道原因吗
Summer Challenge harmonyos ark development framework arkui streamer button effect
Summary of basic concepts of moosefs
26 years old, 0 basic career change software test, from 3K to 16K monthly salary, a super complete learning guide compiled by me
這個flink cdc可以用在做oracle到mysql的,增量同步嗎
MySQL,MVCC详解,快照读在RC、RR下的区别
Type of radar