H5易企秀
周末被领导叫回来加班,说要做一个易企秀一样的页面,然后就有这篇笔记
原计划用几百个计时器去执行,后面放弃了,太难改了,还是选择了animate.css插件,这是一个纯css的插件,只需要引入css就行了
先分析需要什么功能
- 确定要几个页面,页面不能滚动
- 页面通过一个箭头进入下一页,还要监听手势向上滑向下滑
- 进入新的页面一开始必须是空的,然后再用动画把图片文字显示出来
- 插件的使用是给dom元素添加class,监听动画结束后去除class就行
- 进入要有动画,离开要有反方向动画
// 这是插件建议给的用法
function animateCSS(element, animationName, callback) {
const node = document.querySelector(element)
node.classList.add('animated', animationName)
function handleAnimationEnd() {
node.classList.remove('animated', animationName)
node.removeEventListener('animationend', handleAnimationEnd)
if (typeof callback === 'function'){
// 动画结束接入下一个动画
callback()
}
}
node.addEventListener('animationend', handleAnimationEnd)
}
// 使用
animateCSS('.my-element', 'bounce', function() {
// 下一个动画
})
但是上面只能传一个参数,但是这个插件除了动画参数还有执行速度还有执行时间
// animated 必要
// bounce 动画效果必要
// 执行速度也就是总时间,可以不要
// 几秒后开始,可以不要
<div class="animated bounce faster delay-2s">Example</div>
改下代码支持多个传参
var node = document.querySelector(element)
function handleAnimationEnd() {
node.classList.remove('animated', ...animationName)
node.removeEventListener('animationend', handleAnimationEnd)
if (typeof callback === 'function'){
// 动画结束接入下一个动画
callback()
}
}
node.addEventListener('animationend', handleAnimationEnd)
node.classList.add('animated', ...animationName)
// 使用
animateCSS('.my-element', ['bounce','delay-2s'], function() {
// 下一个动画
})
正式开始
css就自己写吧,贴出来太长了
app是全屏,禁止滚动,超出隐藏
下面的page每个都是占满全屏就行
page里的元素都是相对page的定位
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css">
<div id="app">
<div id="page1" class="page">
<img src="img/indexBg.png" />
<img src="img/biaoTi@2x.png" id="page1_title" class="hide">
<img src="img/Lead@2x.png" id="page1_Lead" class="hide">
<img src="img/kaiShi@2x.png" id="page1_kaiShi" class="hide">
</div>
<div id="page2" class="page" style="display: none;" >
<img src="img/tongYongBg.png"/>
<img src="img/biaoTi2@2x.png" id="page2_title" class="hide">
<img src="img/1@2x.png" id="page2_wenZi" class="hide">
<img src="img/kaiShi2@2x.png" id="page2_kaiShi" class="hide">
</div>
...
</div>
<div>
<div id="nextBtn" style="display: none;" onclick="touchDown()">
<img src="img/next.png" class="animated bounce infinite">
</div>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
// 当前页数
var nowPage = 0
// 所有页数的id存储器
var pageArr = ["page1","page2"]
// 是不是可以进入下一页的标记,需要等动画结束才能进入下一页
var flag = false
function init(){
// 给window添加滑动时间监听
last_next()
// 初始化全部
allhide()
// 初始化第一个页面
page1()
}
init()
function allhide(){
$('.hide').hide()
}
function animateCSS(element, animationName, callback) {
var node = document.querySelector(element)
function handleAnimationEnd() {
node.classList.remove('animated', ...animationName)
node.removeEventListener('animationend', handleAnimationEnd)
if (typeof callback === 'function'){
// 动画结束接入下一个动画
callback()
}
}
node.addEventListener('animationend', handleAnimationEnd)
node.classList.add('animated', ...animationName)
// 上面hide隐藏的元素在执行动画的时候要重新显示
$(node).show()
}
function animateCSSOut(element, animationName, callback) {
var node = document.querySelector(element)
function handleAnimationEnd() {
node.classList.remove('animated', ...animationName)
node.removeEventListener('animationend', handleAnimationEnd)
// 退出动画结束后隐藏
$(node).hide()
if (typeof callback === 'function'){
// 动画结束接入下一个动画
callback()
}
}
node.addEventListener('animationend', handleAnimationEnd)
node.classList.add('animated', ...animationName)
}
function last_next(){
var start = 0
document.body.addEventListener("touchstart",function(e){
start = e.changedTouches[0].pageY
})
// 微信页面向上向下拖动会出现橡皮筋,应该取消掉,就是组织页面的touch事件
// 但是普通页面不能这么做,这样连列表都不能滚动
document.body.addEventListener("touchmove",function(e){
e.preventDefault();
},{passive: false})
document.body.addEventListener("touchend",function(e){
var end = e.changedTouches[0].pageY;
if(end>start+100 && flag){
touchDown()
console.log("向下滑")
}else if(start>end+100 && flag){
touchUp()
console.log("向上滑")
}
})
}
function page1(){
animateCSS("#page1_title",["fadeInDownBig"])
animateCSS("#page1_Lead",["zoomInLeft","slow"],function(){
animateCSS("#page1_wenZi",["bounceInUp"],function(){
animateCSS("#page1_kaiShi",["bounceInRight"])
$("#nextBtn").show()
flag = true
})
})
}
function page1out(cb){
animateCSSOut("#page1_Lead",["zoomOutRight"])
animateCSSOut("#page1_wenZi",["bounceOutDown"])
animateCSSOut("#page1_kaiShi",["bounceOutRight"])
animateCSSOut("#page1_title",["fadeOutUpBig"],function(){
cb()
})
}
function page2(cb){
animateCSS("#page2_title",["fadeInDownBig"])
animateCSS("#page2_wenZi",["flipInY","slow"],function(){
animateCSS("#page2_kaiShi",["rubberBand"])
$("#nextBtn").show()
flag = true
})
}
function page2out(cb){
$('#page2_kaiShi').hide()
animateCSSOut("#page2_wenZi",["flipOutY"])
animateCSSOut("#page2_title",["fadeOutUpBig"],function(){
cb()
})
}
function touchUp(){
$("#nextBtn").hide()
flag = false
window[pageArr[nowPage]+"out"](function(){
var lastPage = nowPage;
if(lastPage==pageArr.length-1){
nowPage = 0
}else{
nowPage++;
}
// 上一页效果
$("#"+pageArr[nowPage]).css({
"display":"block",
"z-index":"100"
})
animateCSS('#'+pageArr[nowPage], ['fadeInUp'],function(){
$("#"+pageArr[lastPage]).css({
"display":"none",
"z-index":"1"
})
$("#"+pageArr[nowPage]).css({
"z-index":"1"
})
window[pageArr[nowPage]]()
})
})
}
function touchDown(){
$("#nextBtn").hide()
flag = false
window[pageArr[nowPage]+"out"](function(){
var lastPage = nowPage;
if(lastPage==0){
nowPage = pageArr.length - 1
}else{
nowPage--;
}
// 下一页效果
$("#"+pageArr[nowPage]).css({
"display":"block",
"z-index":"100"
})
animateCSS('#'+pageArr[nowPage], ['fadeInDown'],function(){
$("#"+pageArr[lastPage]).css({
"display":"none",
"z-index":"1"
})
$("#"+pageArr[nowPage]).css({
"z-index":"1"
})
window[pageArr[nowPage]]()
})
})
}
小模块,加班就当练练手了,在加上一个右上角的音频播放,就跟易企秀很像了
代码上传到github上,
预告,下一期公司要做年会大屏幕抽奖
H5易企秀的更多相关文章
- 易企秀 we+ Maka 兔展 四大H5页面制作工具
H5这个由HTML5简化而来的词汇,正通过微信广泛传播.H5是集文字.图片.音乐.视频.链接等多种形式的展示页面,丰富的控件.灵活的动画特效.强大的交互应用和数据分析,高速低价的实现信息传播,非常适合 ...
- 易企秀H5 json配置文件解密分析
最近需要参考下易企秀H5的json配置文件,发现已经做了加密,其实前端的加密分析起来只是麻烦点. 抓包分析 先看一个H5: https://h5.eqxiu.com/s/XvEn30op F12可以看 ...
- H5类似易企秀/编辑器/页面制作/开发/生成工具/软件/源码/授权
代码地址如下:http://www.demodashi.com/demo/14960.html 项目简介 H5DS (HTML5 Design software) 这是一款基于WEB的 H5制作工具. ...
- 如何搭建易企秀H5平台?
导读 易企秀如何开启伪静态支持? 一秀如何开启伪静态? 下载易企秀源码 oschina: http://git.oschina.net/jsper/html5Editor Windows下搭建环境 安 ...
- 易企秀微场景2016最新完整版V10.5,小编亲测修复众多错误
易企秀V10.5更新说明1.修复拨号英文错误2.修复转送场景问题3.修复设置场景密码乱码问题4.修复前台批量删除客户图片5.修复数据收集分页问题6.修复图片分类错乱问题7.修复音乐和特效冲突问题8.修 ...
- 易企CMS仿站标签说明
头部标签: 每个页面都必须加的三大标签(将标签放入header.tpl里面,这样只需在每个模板中调用header.tpl即可): <title>{$seotitle}_{$sitename ...
- 易企CMS主要模板文件介绍
article.tpl 文章内容页模板 catalog.tpl 文章,产品目录页模板 category.tpl 分类页模板 comment.tpl 留言页模板 footer.tpl 页尾模板 head ...
- 易企CMS模板调用标签列表
格式化URL formaturl 参数:type (生成URL类型) 可选值:article,product,category,catalog,comment参数:siteurl (生成URL网站地址 ...
- 【干货】微信场景之H5页面制作免费工具大集合
营销代有手段出,各领风骚数百天.要说现在哪些营销方式最能传播,屡屡刷爆朋友圈的H5页面肯定就是首当其冲的,提到H5页面,就立马想到"围住神经猫",上线微信朋友圈3天的时间便创造了用 ...
随机推荐
- 操作系统OS,Python - 协程(Coroutine)
留坑 参考: https://en.wikipedia.org/wiki/Coroutine https://zh.wikipedia.org/wiki/%E5%8D%8F%E7%A8%8B http ...
- 2.1 MySQL基础使用
本文是课上资料的总结非原创没有转载地址 目录 引言 为什么需要数据库? 数据库和应用程序的关系 MySQL基础使用 一.数据库简介 1.1 简介 1.2 常见数据库管理系统 1.3 MySQL卸载 1 ...
- 金币(0)<P2015_1>
金币 (coin.cpp/c/pas) [问题描述] 国王将金币作为工资,发放给忠诚的骑士.第一天,骑士收到一枚金币:之后两天(第二天和第三天),每天收到两枚金币:之后三天(第四.五.六天),每天收 ...
- MySQL更改默认的root账户密码
编辑mysql的配置文件:my.ini(在MySql安装目录下). 打开配置文件,在文件最后一行添加:skip-grant-tables,然后保存退出 意思为就是在启mysql时不启动grant-ta ...
- nginx 的 content阶段的root指令与alias指令
root 与alias指令 Syntax: alias path; Default: — Context: location Syntax: root path; Default: root html ...
- js中怎么把类数组转化为数组
说起伪数组,首先想到arguments, 这个我们函数参数的一个类数组,是类数组的代表. 1.拥有length属性,可以使用下标来访问元素,这两点和数组相同. 2.不能使用数组的方法,他们不能使用Ar ...
- 4 CSS导航栏&下拉菜单&属性选择器&属性和值选择器
CSS导航栏 熟练使用导航栏,对于任何网站都非常重要 使用CSS你可以转换成好看的导航栏而不是枯燥的HTML菜单 垂直导航栏: <!DOCTYPE html> <html> & ...
- 十三 Spring的通知类型,切入表达式写法
Spring中通知类型: 前置通知:目标方法执行之前进行操作,可以获得切入点信息 后置通知: 目标方法执行之后进行操作,可以获得方法的返回值 环绕通知:在目标方法执行之前和之后进行操作,可以终止目标方 ...
- Python基础-4 运算符
运算符 运算符:以1 + 2为例,1和2被称为操作数,"+" 称为运算符. Python语言支持以下类型的运算符: 算术运算符 比较(关系)运算符 赋值运算符 逻辑运算符 位运算符 ...
- ping命令工具:同时ping多个IP
检测多个ip在同一时间点的响应状态,通过对比来判断哪个ip异常. 下载地址:https://share.weiyun.com/5XCkypG