网页入场动画之 Animate

2024-03-27 23:50
文章标签 网页 动画 入场 animate

本文主要是介绍网页入场动画之 Animate,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

话不多说看效果

提示: gif不动了就刷新下页面 !!!!!!!!!!!!!!!!

在这里插入图片描述
仔细看 Animate 就是动态添加一些它自己封装的一些样式类 这就是用法
但是类前面必须加 animate__animated
在这里插入图片描述

1、安装 animate

npm install animate.css --save

2、main 引入

import animated from 'animate.css' // npm install animate.css --save安装,再引入
Vue.use(animated)

下面就是一些动态添加样式的方法

Animate 还有很多的动画 这只是冰山一角 具体可以去 去官网看
这里我加了鼠标滚动监听,上滚删类 下滚添加类

// 这是一个vue的组件  可直接拿走  引入的组件是下一段代码
<template><div class="hello"><h1 :class="css1">帅帅1</h1><h2 :class="css2">帅帅2</h2><h3 :class="css3">帅帅3</h3><h4 :class="css4">帅帅4</h4><Hell2></Hell2></div>
</template><script>
import Hell2 from "./hell2.vue";
export default {name: "HelloWorld",components: {Hell2},data() {return {css1: "",css2: "",css3: "",css4: ""};},created() {this.cssa();this.cssb();this.cssc();this.cssd();},mounted() {window.addEventListener("scroll", this.handleScroll, true); // 监听(绑定)滚轮 滚动事件},methods: {css() {this.css1 = "";this.css2 = "";this.css3 = "";this.css4 = "";},cssa() {this.css1 = "animate__animated animate__fadeInLeft ";},cssb() {this.css2 = "animate__animated animate__fadeInRight";},cssc() {this.css3 = "animate__animated animate__bounceInDown animate__delay-1s";},cssd() {this.css4 = "animate__animated animate__bounceInUp animate__delay-1s";},handleScroll() {// 监听鼠标滚动// 页面滚动距顶部距离var scrollTop =window.pageYOffset ||document.documentElement.scrollTop ||document.body.scrollTop;var scroll = scrollTop - this.i;this.i = scrollTop;if (scroll < 0) {// 鼠标上滚this.css();} else {// 鼠标下滚this.cssa();this.cssb();this.cssc();this.cssd();}}}
};
</script><!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
.hello {// height: 1500px;display: flex;flex-wrap: wrap;background-size: c;background: url(../assets/bg.png) no-repeat;h1 {width: 50%;margin-top: 300px;text-align: center;height: 200px;line-height: 200px;background: #333;}h2 {margin-top: 300px;width: 50%;text-align: center;height: 200px;line-height: 200px;background: #444;}h3 {width: 50%;text-align: center;height: 200px;line-height: 200px;background: #555;margin: 0;}h4 {width: 50%;text-align: center;height: 200px;line-height: 200px;background: #666;margin: 0;}
}
</style>

这里面有组件进入可视区域监听

// 这是上面引入的那个组件  改吧改吧就是你想要的效果
<template><div class="hello"><h5 :class="css5">帅帅5</h5><h6 :class="css6">帅帅6</h6></div>
</template><script>
export default {name: "HelloWorld",data() {return {css5: "",css6: ""};},created() {},mounted() {window.addEventListener("scroll", this.scrollHandle, true); // 监听 监听元素是否进入/移出可视区域},methods: {csse() {this.css5 ="animate__animated animate__fadeInTopLeft animate__delay-0.5s animate__slow-5s";// window.removeEventListener('scroll', this.scrollHandle, true); // 记得在适当的时候移除事件监听},cssf() {this.css6 ="animate__animated animate__fadeInRightBig animate__delay-0.5s animate__slow-5s";// window.removeEventListener('scroll', this.scrollHandle, true); // 记得在适当的时候移除事件监听},scrollHandle() {const offset = this.$el.getBoundingClientRect();const offsetTop = offset.top;const offsetBottom = offset.bottom;// const offsetHeight = offset.height;// 进入可视区域// console.log(offsetTop,offsetBottom)if (offsetTop <= window.innerHeight && offsetBottom >= 0) {// console.log('进入可视区域');// do something...this.csse();this.cssf();} else {// console.log('移出可视区域');// this.enabledPause = false;// do something...this.css5 = "";this.css6 = "";}}}
};
</script><!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
.hello {height: 1500px;display: flex;flex-wrap: wrap;width: 100%;margin-top: 500px;overflow: hidden;h5 {width: 50%;text-align: center;height: 200px;line-height: 200px;background: #777;margin: 0;}h6 {width: 50%;text-align: center;height: 200px;line-height: 200px;background: #888;margin: 0;}
}
</style>

-----------------------------------------------你在变强 也在变亮--------------------------------------------------

这篇关于网页入场动画之 Animate的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/853815

相关文章

问题-windows-VPN不正确关闭导致网页打不开

为什么会发生这类事情呢? 主要原因是关机之前vpn没有关掉导致的。 至于为什么没关掉vpn会导致网页打不开,我猜测是因为vpn建立的链接没被更改。 正确关掉vpn的时候,会把ip链接断掉,如果你不正确关掉,ip链接没有断掉,此时你vpn又是没启动的,没有域名解析,所以就打不开网站。 你可以在打不开网页的时候,把vpn打开,你会发现网络又可以登录了。 方法一 注意:方法一虽然方便,但是可能会有

网页脚本输入这么简单

如何在网页中进行脚本操作呢? 研究了一下,很简单,用google浏览器的Console直接操作javaScript。思路: Created with Raphaël 2.1.0 开始 输入(如何输入) 点击(如何点击) 结束 下面是,通过脚本刷直播屏的实现,直接在Console输入即可 var words=new Arra

ArkTS开发系列之导航 (2.7动画)

上篇回顾: ArkTS开发系列之导航 (2.6 图形) 本篇内容:动画的学习使用 一、 知识储备 1. 布局更新动画 包含显式动画(animateTo)和属性动画(animation) 动画类型名称特点显式动画闭包内的变化都会触发动画执行, 可以做较复杂的动画属性动画属性变化时触发动画执行, 设置简单 说白了,显示动画就是靠闭包事件触发,属性动画是挂在组件身上的属性变化触发 显式动画

Android 扇形网络控件 - 无网络视图(动画)

前言 一般在APP没有网络的情况下,我们都会用一个无网络的提示图标,在提示方面为了统一app的情况,我们一般使用简单的提示图标,偶尔只需要改变一下图标的颜色就一举两得,而不需要让PS来换一次颜色。当然app有图标特殊要求的就另当别论了。 效果图 当你第一眼看到这样的图,二话不说直接让UI给你切一张图标来的快对吧,我其实开始也是这么想的,但是到了做的app越来越多的时候,你就会发现就算是用

前端微信网页授权+WebSocket

这篇教程只介绍前端需要做的工作; 注意: 1,开发者必须关注公众号,且是公众号下的开发者; 2,域名地址必须是公众号绑定的域名地址; 微信授权需要调试工具:微信web开发者工具; 参考微信文档:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140842 微信授权,前端与服务端的交互只涉及appId,code,和re

AIGC-Animate Anyone阿里的图像到视频 角色合成的框架-论文解读

Animate Anyone: Consistent and Controllable Image-to-Video Synthesis for Character Animation 论文:https://arxiv.org/pdf/2311.17117 网页:https://humanaigc.github.io/animate-anyone/ MOTIVATION 角色动画的

使用Dash开发交互式数据可视化网页--响应式编程

交互性 后续的操作前,需要安装如下Python包 pip install dash==0.20.0 # The core dash backendpip install dash-renderer==0.11.2 # The dash front-endpip install dash-html-components==0.8.0 # HTML componentspip inst

使用Dash开发交互式数据可视化网页--页面布局

Dash应用布局 后续的操作前,需要安装如下Python包 pip install dash==0.20.0 # The core dash backendpip install dash-renderer==0.11.2 # The dash front-endpip install dash-html-components==0.8.0 # HTML componentspip

PriorityQueue详解(含动画演示)

目录 PriorityQueue详解1、PriorityQueue简介2、PriorityQueue继承体系3、PriorityQueue数据结构PriorityQueue类属性注释完全二叉树、大顶堆、小顶堆的概念☆PriorityQueue是如何利用数组存储小顶堆的?☆利用数组存储完全二叉树的好处? 4、PriorityQueue的`offer`方法动画演示offer插入过程: 5、Pri

「Debug R」一个Seurat导致的Rstudio网页版经常被终止的bug

在网页版的Rstuio加载Seurat时,等待了很久都没有成功,刷新网页后就出现了如下的提示   报错信息 测试了其他包,例如ggplot2,都没有任何问题,唯独是Seurat出现了问题,因此我用关键词"seurat cause rsession terminated" 进行搜索,发现有人在Rstudio的社区上提出了这个问题,看来我并不是一个人遇到这个问题。 我尝试里帖子h