page-refresh
Version:
帅气优雅的移动端下拉刷新,零依赖,高性能,丰富主题,强扩展性
612 lines (526 loc) • 14.4 kB
CSS
/**
* minirefresh 的样式
*/
.minirefresh-wrap {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
/*
* 去除wrap层的滚动条,确保只有scrol层有滚动条
*/
overflow-x: hidden;
overflow-y: hidden;
/**
* 使用3d加速时,尽可能的使用index,防止浏览器默认给后续的元素创建复合层渲染
* 因为CSS3中,如果这个元素添加了硬件加速,并且index层级比较低,
* 在这个元素的后面其它元素(层级比这个元素高的,或者相同的,并且releative或absolute属性相同的),会默认变为复合层渲染
* 如果处理不当会极大的影响性能,可以用chrome的rending查看
*/
z-index: 1;
}
/**
* 内容区域的布局
* 一般来说布局内会包含上拉加载动画
* 但是不会包含下拉刷新动画
*/
.minirefresh-scroll {
position: absolute;
top: 0;
/*
* 标明了top和bottom 滑动的就是minirefresh-scroll而不再是document.body
*/
bottom: 0;
width: 100%;
-webkit-overflow-scrolling: touch;
overflow-y: auto;
/*
* index默认要高于downwrap
*/
z-index: 1;
}
/**
* 如果开启了body监听scroll,需要将position都设置为releative
* 否则监听不到
*/
.body-scroll-wrap {
position: relative;
}
/**
* 硬件加速样式,
* 开启后可以GPU渲染
* 但是代价是该图层需单独渲染
* 所以虽然效果不错,但慎用
* 容器有复杂动画时可以开启
*/
.minirefresh-hardware-speedup {
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
transform: translateZ(0);
}
.minirefresh-hidden {
display: none ;
}
/*
* 滚动条轨道背景
* */
.mescroll-bar::-webkit-scrollbar-track {
background-color: transparent;
}
/*
* 滚动条轨道宽度
* */
.minirefresh-scroll::-webkit-scrollbar {
width: 6px;
}
/*
* 滚动条游标
* */
.minirefresh-scroll::-webkit-scrollbar-thumb {
border-radius: 6px;
background-color: #ccc;
}
/*
* 滚动条游标鼠标经过的颜色变化
* */
.minirefresh-scroll::-webkit-scrollbar-thumb:hover {
background-color: #aaa;
}
@-webkit-keyframes minirefresh-fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes minirefresh-fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes minirefresh-fade-out {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
@keyframes minirefresh-fade-out {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
@keyframes minirefresh-rotate {
0% {
-webkit-transform: rotateZ(0deg);
transform: rotateZ(0deg);
-moz-transform: rotate(0deg);
}
100% {
-webkit-transform: rotateZ(360deg);
transform: rotateZ(360deg);
-moz-transform: rotate(360deg);
}
}
@-webkit-keyframes minirefresh-rotate {
0% {
-webkit-transform: rotateZ(0deg);
transform: rotateZ(0deg);
-moz-transform: rotate(0deg);
}
100% {
-webkit-transform: rotateZ(360deg);
transform: rotateZ(360deg);
-moz-transform: rotate(360deg);
}
}
.minirefresh-rotate {
-webkit-animation: minirefresh-rotate 0.6s linear infinite;
animation: minirefresh-rotate 0.6s linear infinite;
}
.minirefresh-fade-in {
-webkit-animation: minirefresh-fade-in .5s linear forwards;
animation: minirefresh-fade-in .5s linear forwards;
}
.minirefresh-fade-out {
pointer-events: none;
-webkit-animation: minirefresh-fade-out .5s linear forwards;
animation: minirefresh-fade-out .5s linear forwards;
}
/**
* 重写部分toTop样式,可以这样重新(没有空格)
* .minirefresh-totop.minirefresh-theme-default(或其它主题)
* 可以在外部重新这个样式来达到自定义的目的
* 由于totop和theme并列,所以这样取了
*/
.minirefresh-totop {
position: fixed;
z-index: 9990;
right: 10px;
bottom: 30px;
width: 36px;
height: 36px;
border-radius: 50%;
background-image: url(c141fb4f38e8f17224e63e8e4d5e1543.png);
background-size: 100% 100%;
}
/**
* default 主题的样式
*/
.minirefresh-theme-default .minirefresh-downwrap {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 75px;
}
.minirefresh-theme-default .minirefresh-upwrap {
min-height: 30px;
padding: 15px 0;
text-align: center;
}
.minirefresh-theme-default .downwrap-content {
/*position: absolute;*/
width: 100%;
padding: 10px 0;
text-align: center;
}
.minirefresh-theme-default .minirefresh-downwrap .downwrap-progress,
.minirefresh-theme-default .minirefresh-upwrap .upwrap-progress {
display: inline-block;
width: 16px;
height: 16px;
border-radius: 50%;
border: 1px solid gray;
margin-right: 8px;
border-bottom-color: transparent;
vertical-align: middle;
}
.minirefresh-theme-default .minirefresh-downwrap .downwrap-success,
.minirefresh-theme-default .minirefresh-downwrap .downwrap-error {
border-bottom-color: gray;
}
.minirefresh-theme-default .minirefresh-downwrap .downwrap-tips,
.minirefresh-theme-default .minirefresh-upwrap .upwrap-tips {
display: inline-block;
font-size: 12px;
color: gray;
vertical-align: middle;
}/**
* 滑动抽屉效果
* 样式和3D抽屉类似,但是为了遵循 一个主题实现一个效果的原则
* 单独独立成主题,而不是简单的将两个功能复用到一个主题
*/
.minirefresh-theme-jianshu .minirefresh-downwrap {
position: absolute;
top: 0;
left: 50%;
height: 50px;
/* background: #000000; */
z-index: 999;
width:50px;
margin-left:-25px;
}
.minirefresh-theme-jianshu .minirefresh-downwrap .downwrap-content {
width: 100%;
margin-top: 0px;
text-align: center;
height: 50px;
line-height: 50px;
padding: 0;
}
.minirefresh-theme-jianshu .minirefresh-downwrap .drawer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
background: #ffffff;
text-align: center;
background-clip: padding-box;
box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
height:100%;
border-radius: 50%;
}
.minirefresh-theme-jianshu .drawer .drawer-mask {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #D3D3D3;
/*
* 最终的透明度是计算生成的
*/
opacity: .4;
}
.minirefresh-theme-jianshu .minirefresh-downwrap .downwrap-progress{
display: inline-block;
width: 25px;
height: 25px;
border-radius: 50%;
border: 1px solid gray;
margin: auto auto;
border-bottom-color: transparent;
vertical-align: middle;
background: url(http://mdn.csdu.net/img/group.png) no-repeat;
background-position:center;
background-size:100%;
border:none;
}/**
* 仿淘宝的主题
* 支持淘宝二楼效果
*/
.minirefresh-theme-taobao .minirefresh-downwrap {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 800px;
}
.minirefresh-theme-taobao .minirefresh-downwrap .downwrap-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url(a5b5c3ee36eb3fe93e446724741ae2a1.jpg);
background-size: 100% 100%;
}
.minirefresh-theme-taobao .minirefresh-downwrap .downwrap-moon {
position: absolute;
width: 120px;
height: 80px;
bottom: 80px;
margin-left: -60px;
left: 50%;
background-image: url(1d7a516a4e95ba32db0b1b3a94412c34.png);
background-size: 100% 100%;
}
.minirefresh-theme-taobao .minirefresh-downwrap .downwrap-content {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
text-align: center;
}
/**
* 以下是进入和退出秘密花园
*/
.minirefresh-theme-taobao .minirefresh-downwrap .secret-garden-bg-in {
transform: scale(1.5) translateZ(0px);
-webkit-transform: scale(1.5) translateZ(0px);
transition: 1000ms;
-webkit-transition: 1000ms;
}
.minirefresh-theme-taobao .minirefresh-downwrap .secret-garden-bg-out {
transform: scale(1) translateZ(0px);
-webkit-transform: scale(1) translateZ(0px);
transition: 1000ms;
-webkit-transition: 1000ms;
}
.minirefresh-theme-taobao .minirefresh-downwrap .secret-garden-moon-in {
transform: translateY(-120px) translateZ(0px);
-webkit-transform: translateY(-120px) translateZ(0px);
transition: 1000ms;
-webkit-transition: 1000ms;
}
.minirefresh-theme-taobao .minirefresh-downwrap .secret-garden-moon-out {
transform: translateY(0px) translateZ(0px);
-webkit-transform: translateY(0px) translateZ(0px);
transition: 1000ms;
-webkit-transition: 1000ms;
}
/**
* 重新tips
*/
.minirefresh-theme-taobao .minirefresh-downwrap .downwrap-tips {
font-size: 14px;
color: white;
}
.minirefresh-theme-taobao .minirefresh-downwrap .downwrap-progress {
display: inline-block;
width: 16px;
height: 16px;
border-radius: 50%;
border: 1px solid white;
margin-right: 8px;
border-bottom-color: transparent;
vertical-align: middle;
}
/**
* 微信小程序的主题
*/
@-webkit-keyframes ball-beat {
50% {
opacity: 1;
-webkit-transform: scale(0.75);
transform: scale(0.75);
}
100% {
opacity: 0.3;
-webkit-transform: scale(1);
transform: scale(1);
}
}
@keyframes ball-beat {
50% {
opacity: 1;
-webkit-transform: scale(0.75);
transform: scale(0.75);
}
100% {
opacity: 0.3;
-webkit-transform: scale(1);
transform: scale(1);
}
}
.ball-beat > .dot {
opacity: 0.3;
background-color: #444444;
width: 8px;
height: 8px;
border-radius: 100%;
margin: 2px;
display: inline-block;
}
.loading-applet .ball-beat .dot {
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation: ball-beat 1s 0s infinite linear;
animation: ball-beat 1s 0s infinite linear;
}
.loading-applet .ball-beat > .dot:nth-child(2) {
-webkit-animation-delay: 0.3s ;
animation-delay: 0.3s ;
}
.loading-applet .ball-beat > .dot:nth-child(3) {
-webkit-animation-delay: 0.6s ;
animation-delay: 0.6s ;
}
.minirefresh-theme-applet .minirefresh-downwrap {
position: absolute;
top: 0;
left: 0;
height: 50px;
}
.minirefresh-theme-applet .minirefresh-downwrap .downwrap-content {
width: 100%;
margin-top: 20px;
text-align: center;
}/**
* 3D抽屉效果
*/
.minirefresh-theme-drawer3d .minirefresh-downwrap {
position: absolute;
top: 0;
left: 0;
height: 200px;
background: #000000;
/*
* 开启3D视角,经测试,就算不写,只要有translateZ,在iOS下默认也有这个效果
* http://www.w3cplus.com/css3/transform-basic-property.html
* */
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
/**
* 隐藏不可见元素
*/
backface-visibility: hidden
}
.minirefresh-theme-drawer3d .minirefresh-downwrap .downwrap-content {
width: 100%;
margin-top: 20px;
text-align: center;
}
/**
* 由于父容器开启了preserve-3d 3D视角(iOS中只有有translateZ就相当于会默认开启),所以如果直接是drawer3d进行变换,会有一部分无法显示
* 需要中间来一个舞台,舞台占满宽高
*/
.minirefresh-theme-drawer3d .state-3d {
width: 100%;
height: 100%;
transform: translateZ(0);
-webkit-transform: translateZ(0);
perspective: 100px;
-webkit-perspective: 100px;
/*
* 视角和子元素的origin保持一致
*/
perspective-origin: center bottom;
-webkit-perspective-origin: center bottom;
}
.minirefresh-theme-drawer3d .drawer3d {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
background: #FFFFFF;
text-align: center;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-transform-origin: center bottom;
transform-origin: center bottom;
}
.minirefresh-theme-drawer3d .drawer3d .drawer3d-mask {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #D3D3D3;
/*
* 最终的透明度是计算生成的
*/
opacity: .4;
}/**
* 滑动抽屉效果
* 样式和3D抽屉类似,但是为了遵循 一个主题实现一个效果的原则
* 单独独立成主题,而不是简单的将两个功能复用到一个主题
*/
.minirefresh-theme-drawerslider .minirefresh-downwrap {
position: absolute;
top: 0;
left: 0;
height: 200px;
background: #000000;
z-index: 999;
}
.minirefresh-theme-drawerslider .minirefresh-downwrap .downwrap-content {
width: 100%;
margin-top: 20px;
text-align: center;
}
.minirefresh-theme-drawerslider .minirefresh-downwrap .drawer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
background: #FFFFFF;
text-align: center;
background-clip: padding-box;
box-shadow: 0 1px 2px rgba(0,0,0,.3);
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.minirefresh-theme-drawerslider .drawer .drawer-mask {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #D3D3D3;
/*
* 最终的透明度是计算生成的
*/
opacity: .4;
}
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJwYWdlcmVmcmVzaC5jc3MiLCJzb3VyY2VSb290IjoiIn0=*/