当前位置:网站首页>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
边栏推荐
- qt5.14.2连接ubuntu20.04的mysql数据库出错
- Matplotlib histogram
- As for the domestic Kirin system running QT, it can be run on the command line but cannot be run by double clicking (no response)
- Wechat public account development, send message reply text
- Common PostgreSQL data operation notes: time
- 科大讯飞 AI 学习机暑期新品发布会 AI + 教育深度结合再创产品新高度
- A mysql IBD file is too large processing record
- Flame retardant test of aluminum sheet as/nzs 1530.1 non combustible materials
- ASP动态创建表格 Table
- MooseFS基本概念总结
猜你喜欢

Three development trends of enterprise application viewed from the third technological revolution

In the shop project, implement a menu (add, delete, modify and query)

Dynamics 365online lookup lookup field multiple selection

Deep learning remote sensing data set

Reading notes on how to connect the network - Web server request and response (V)

Small library project summary

掌握这28张图,面试再也不怕被问TCP知识了

Huawei cloud AOM version 2.0 release

美国隧道法ASTM E84 表面阻燃测试

软件测试方法和技术知识点有哪些?
随机推荐
What are the software testing methods and technical knowledge points?
Is it safe to bind securities accounts to flush? Which securities firm can bind flush after opening an account
新手必须知道的 Kubernetes 架构
Résumé du projet de petite bibliothèque
联通入库|需要各地联通公司销售其产品的都需要先入总库
Small library project summary
Daily question brushing record (VIII)
证券开户选择哪个证券另外想问,现在在线开户安全么?
掌握这28张图,面试再也不怕被问TCP知识了
Golang operation etcd
【无工具搭建PHP8+oracle11g+Windows环境】内网/无网络/Win10/PHP连接oracle数据库实例
Flame retardant test of aluminum sheet as/nzs 1530.1 non combustible materials
Taro2.* applet configuration sharing wechat circle of friends
数论-整除分块
Final training simple address book c language
89. (cesium article) cesium aggregation diagram (custom picture)
Wechat public account development, send message reply text
Does rapid software delivery really need to be at the cost of security?
状态管理 利用Session限制页面访问 只有通过登录验证SessionLogin.aspx才能访问Session.aspx
CSDN failed to replicate problem