mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
update for motion
This commit is contained in:
parent
cc9d039c80
commit
ec7a6003e8
8
components/antacss/index.md
Normal file
8
components/antacss/index.md
Normal file
@ -0,0 +1,8 @@
|
||||
# CSS and Ease
|
||||
|
||||
- category: Animation
|
||||
- chinese: 样式缓动函数
|
||||
- order: 3
|
||||
- nodemos: true
|
||||
---
|
||||
待定
|
113
components/naturalmotion/index.md
Normal file
113
components/naturalmotion/index.md
Normal file
@ -0,0 +1,113 @@
|
||||
# Natural Motion
|
||||
|
||||
- category: Animation
|
||||
- chinese: 自然运动
|
||||
- order: 0
|
||||
- nodemos: true
|
||||
---
|
||||
|
||||
现实物体照着一定节奏移动,并不是一开始就移动很快的。
|
||||
|
||||
当我们打开现代家具的门或抽屉时,首先会让它加速,然后慢下来。
|
||||
|
||||
当电梯开关门时,它在打开或关闭时都有一段缓冲带,是先加速,然后慢下来。
|
||||
|
||||
当某个东西往下掉时,首先是越掉越快,撞到地上后回弹,最终才又碰触地板。
|
||||
|
||||
|
||||
### 质量和重量
|
||||
|
||||
在物理世界里,是以力量附加到物体对象里,加上自身的质量才完成一段动画。力量的持续时间决定物体的加速,减速与改变方向。
|
||||
|
||||
动画停止与启动都不是瞬间完成的,因它需要一段缓冲的时间来加速或减速,因此,当动画有突然启动,停止或改变方向,都会显得很不自然。
|
||||
|
||||
#### 自然缓动
|
||||
不要用直线缓动Linear做物体出入动画的缓动;注:Linear函数可做循环动画函数;
|
||||
|
||||
如下图所示,在没有缓动的情况下启动与停止都显得突兀,感觉动画还没结束就停止了,所以在物体运动中避免直线运动;
|
||||
|
||||
<script src="/static/TweenMax.min.js"></script>
|
||||
<script src="/static/motion.js"></script>
|
||||
<div id="J-Linear">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function (){
|
||||
new Motion("#J-Linear",{lineData:[{open:[],end:[],stroke:"#f2666c"},{open:[0.455, 0.03, 0.515, 0.955],end:[0.455, 0.03, 0.515, 0.955],stroke:"#71B5DE",openEaseName:"easeInOutQuad",endEaseName:"easeInOutQuad"},],mask:false});
|
||||
})
|
||||
</script>
|
||||
|
||||
上图所示缓动函数:红:Linear 蓝:easeInOutQuad;
|
||||
|
||||
|
||||
|
||||
|
||||
#### 出入动画
|
||||
不要做单向动画,进场后不做出场,直接消失元素或回到原点,会让整个画面不协调,反相只出不进也一样;
|
||||
|
||||
所以有动画的进场必须要有动画的出场,包括导航上的动画;
|
||||
|
||||
<div id="J-Symmetric">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function (){
|
||||
new Motion("#J-Symmetric",{lineData:[
|
||||
{open:[0.455, 0.03, 0.515, 0.955],end:[],openEaseName:"easeInOutQuad",endEaseName:"null",stroke:"#f2666c"},
|
||||
{open:[0.645, 0.045, 0.355, 1],end:[0.645, 0.045, 0.355, 1],stroke:"#71B5DE",openEaseName:"easeInOutCubic",endEaseName:"easeInOutCubic"}],
|
||||
mask:false,exposure:"top"});
|
||||
})
|
||||
</script>
|
||||
|
||||
上图所示缓动函数:红:easeInOutQuad 蓝:easeInOutCubic;
|
||||
|
||||
|
||||
|
||||
|
||||
##### 场外出入
|
||||
场外出入需要考虑力量与引力的关系,如向空中抛物体时,开始时力量大于引力时,速度是最快的,
|
||||
|
||||
到达一定高度后,随着力量的减少,速度也跟随着降低,物体达到最高点后,力量等于引力或小于引力时,物体随之下降;
|
||||
|
||||
所以在快到达最高点和掉下来时有一定缓冲带;不要做图示红色球体下降时的缓动;
|
||||
|
||||
<div id="J-Entry">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function (){
|
||||
new Motion("#J-Entry",{lineData:[
|
||||
{open:[0.25, 0.46, 0.45, 0.94],end:[0.25, 0.46, 0.45, 0.94],openEaseName:"easeOutQuad",endEaseName:"easeOutQuad",stroke:"#f2666c"},
|
||||
{open:[0.215, 0.61, 0.355, 1],end:[0.55, 0.055, 0.675, 0.19],stroke:"#71B5DE",openEaseName:"easeOutCubic",endEaseName:"easeInCubic"}],
|
||||
mask:true,exposure:"bottom"});
|
||||
})
|
||||
</script>
|
||||
|
||||
上图所示缓动函数:红:easeOutQuad,easeOutQuad 蓝:easeOutCubic,easeInCubic;
|
||||
|
||||
示例组件:<a href="/components/message/">Message全局提示</a>,<a href="/components/dropdown/">Dropdown下拉菜单</a>
|
||||
|
||||
#### 弹性动画
|
||||
|
||||
1.如蹦极跳下来时,刚跳下时速度很快,到达绳子的长度后,由于物体的重量再将绳子拉长再反弹,弹动几次后才停下。
|
||||
|
||||
动画里也由质量来决定它的反弹,一般元素最好只弹动一次就够了,收回时可以用向下浮动再上拉或直接前缓动,可适用在下拉框与弹出元素;
|
||||
|
||||
2.如球类物体掉地上的后,反弹几次后停止;
|
||||
|
||||
注:
|
||||
1.曲线图用的是3次贝塞尔曲线,没法表示Bounce,所以用line替换;
|
||||
2.弹性动画最好结合alpha;
|
||||
<div id="J-Back">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function (){
|
||||
new Motion("#J-Back",{lineData:[
|
||||
{open:[],end:[0.455, 0.03, 0.515, 0.955],openEaseName:"easeOutBounce",endEaseName:"easeInOutQuad",stroke:"#70f266"},
|
||||
{open:[0.175, 0.885, 0.32, 1.275],end:[0.6, -0.28, 0.735, 0.045],stroke:"#71B5DE",openEaseName:"easeOutBack",endEaseName:"easeInBack"}],
|
||||
mask:false,exposure:"top"});
|
||||
})
|
||||
</script>
|
||||
|
||||
上图所示缓动函数:红:easeOutBounce,easeInOutQuad 蓝:easeOutBack,easeInBack;
|
40
components/pagetransition/index.md
Normal file
40
components/pagetransition/index.md
Normal file
@ -0,0 +1,40 @@
|
||||
# Page transition
|
||||
|
||||
- category: Animation
|
||||
- chinese: 单页面转场
|
||||
- order: 2
|
||||
- nodemos: true
|
||||
---
|
||||
###单页面转场动画
|
||||
|
||||
从内容A到内容B的转变过程时能有效的吸引用户注意力,突出视觉中心,提高整体视觉效果。
|
||||
|
||||
####视觉连贯性
|
||||
|
||||
####三类元素(Adding ,Receding,Normal)
|
||||
|
||||
Adding: 新加入的信息元素应被告知如何使用,从页面转变的信息元素需被重新识别。
|
||||
|
||||
Receding: 与当前页无关的信息元素应采用适当方式移除
|
||||
|
||||
Normal: 指那些从转场开始到结束都没有发生变化的信息元素
|
||||
|
||||
|
||||
· 大页面转场可采用淡入淡出的形式
|
||||
|
||||
· 小的信息元素排布最好根据一定的路径层次依次进场 区分维度层级 来凸显量级
|
||||
|
||||
####可折叠面板
|
||||
|
||||
对于信息元素内容区域的延伸,显示信息元素和进一步内容对象之间的直接连接。被展开的信息区域内容按照一定的路劲依次进场。信息元素在收起时在视觉上整齐划一。
|
||||
|
||||
####对象展开
|
||||
|
||||
信息元素被扩大发现其隐藏的内容,通过缩放对象的遮罩来显示隐藏的内容。这样可减少页面新的信息元素(Incoming)的增加,直接从页面本身的信息元素来做变形可提高用户对新内容的认知和识别。
|
||||
|
||||
####弹出框动效
|
||||
|
||||
从一个触发点触发一个弹出框时,弹框从所触发区域弹出,且触发区域视觉上基本保持不变。这样让触发区域和弹出区域有所关联,提高用户对新内容的认知。
|
||||
|
||||
|
||||
|
105
components/resInteraction/index.md
Normal file
105
components/resInteraction/index.md
Normal file
@ -0,0 +1,105 @@
|
||||
# Response ITN
|
||||
|
||||
- category: Animation
|
||||
- chinese: 响应交互
|
||||
- order: 1
|
||||
- nodemos: true
|
||||
---
|
||||
响应交互一般是指我们在浏览页面时,点击元素时动画给我们视觉上的反馈,每个交互动效都能给我们带来不同视觉效果。
|
||||
|
||||
如搜索框,当你点击准备输入时,icon将会跑到右边方便点击,当然你按回车也是可以提交表单的;在你没有输入文字时,icon又会恢愎到原来的地置,但当你输入了文字后,icon将会停留在右边;
|
||||
|
||||
### 按钮类表面效果
|
||||
|
||||
按钮上的hover或click效果,随着你的鼠标事件而改变自身或增加元素在按钮上;
|
||||
|
||||
以下按钮对组件按钮的修改,只做示例,具体还需看组件;
|
||||
<link rel="stylesheet" href="/static/motion.css">
|
||||
<link rel="stylesheet" href="/static/motionDome.css">
|
||||
<script src="/static/motionDome.js"></script>
|
||||
<div style="overflow: hidden;">
|
||||
<div style="width:200px;float:left;margin-right:60px">
|
||||
<p style="text-align: center;"> 1.按钮表面效果;</p>
|
||||
<div class="ant-btn-domebox">
|
||||
<a class="ant-btn ant-btn-primary">我是按钮</a>
|
||||
<a class="ant-btn ant-btn-primary ant-btn-ripple">
|
||||
点击涟漪按钮
|
||||
</a>
|
||||
<a class="ant-btn ant-btn-ripple">
|
||||
点击涟漪按钮
|
||||
</a>
|
||||
<button class="ant-btn ant-btn-ghost ant-btn-circle-outline ant-btn-lg" style="display: block;">
|
||||
<span class="anticon anticon-search"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width:200px;float:left;">
|
||||
<p style="text-align: center;"> 2.无素结合切换;</p>
|
||||
<div class="ant-btn-domebox">
|
||||
<button class="ant-btn ant-btn-primary ant-btn-ripple ant-btn-load ">
|
||||
<text>加载按钮</text>
|
||||
<span class='anticon anticon-loading'></span>
|
||||
</button>
|
||||
<button class="ant-btn ant-btn-primary ant-btn-reload ant-btn-ripple">
|
||||
<span class="anticon anticon-reload"></span>
|
||||
<text>刷新</text>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
### 元素类呈现效果
|
||||
|
||||
元素呈现指点击或滑过展现相关的内容或提示,如下拉菜单或弹出框等;
|
||||
|
||||
注:物体弹出点要从点击点出现,不要做凭空出现;
|
||||
|
||||
|
||||
<div style="overflow: hidden;">
|
||||
|
||||
<div style="width:200px;float:left;margin-right:60px">
|
||||
<p style="text-align: center;"> 1.icon菜单(点放大模式)</p>
|
||||
<div class="ant-btn-domebox" >
|
||||
|
||||
|
||||
<button class="ant-btn ant-btn-ghost ant-btn-circle-outline ant-btn-lg ant-btn-ripple ant-btn-listtip" style="float:right;margin:0" data-id="J-Tip">
|
||||
<span class="anticon anticon-bars"></span>
|
||||
</button>
|
||||
<div class="ant-anim-dometip ant-anim-topArrow scale-origin-iconTopRight" style="display:none;" id="J-Tip">
|
||||
<ul>
|
||||
<li>第一排文字元素</li>
|
||||
<li>第二排文字元素</li>
|
||||
<li>第三排文字元素</li>
|
||||
<li>第四排文字元素</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="width:200px;float:left;">
|
||||
<p style="text-align: center;">2.下拉菜单(下滑模式)</p>
|
||||
<div class="ant-btn-domebox">
|
||||
|
||||
|
||||
<div class="ant-dropdown-wrap">
|
||||
<button class="ant-btn ant-btn-primary ant-btn-menu ant-btn-dropdown ant-btn-ripple">
|
||||
<span>菜单按钮</span>
|
||||
<span class="anticon anticon-down"></span>
|
||||
</button>
|
||||
<div class="ant-dropdown ant-anim-dometip scale-origin-top">
|
||||
<div class="ant-dropdown-con">
|
||||
<ul>
|
||||
<li>第一排文字元素</li>
|
||||
<li>第二排文字元素</li>
|
||||
<li>第三排文字元素</li>
|
||||
<li>第四排文字元素</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
80
static/motion.css
Normal file
80
static/motion.css
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
/******动画名称******/
|
||||
|
||||
.scale-open{
|
||||
display: block !important;
|
||||
animation: ToScale .4s cubic-bezier(0.08, 0.82, 0.17, 1);
|
||||
-webkit-animation: ToScale .4s cubic-bezier(0.08, 0.82, 0.17, 1);
|
||||
}
|
||||
.scale-close{
|
||||
display: block !important;
|
||||
animation: FromScale .4s cubic-bezier(0.6, 0.04, 0.98, 0.34);
|
||||
-webkit-animation: FromScale .4s cubic-bezier(0.6, 0.04, 0.98, 0.34);
|
||||
}
|
||||
.scale-origin-top{
|
||||
transform-origin: top;
|
||||
}
|
||||
.scale-origin-left{
|
||||
transform-origin: left;
|
||||
}
|
||||
.scale-origin-bottom{
|
||||
transform-origin: bottom;
|
||||
}
|
||||
.scale-origin-right{
|
||||
transform-origin: right;
|
||||
}
|
||||
.scale-origin-iconTopRight{
|
||||
transform-origin: calc(100% - 10px) -10px;
|
||||
}
|
||||
.margin-top-open{
|
||||
display: block !important;
|
||||
animation: ToMaginTop .4s cubic-bezier(0.08, 0.82, 0.17, 1);
|
||||
-webkit-animation: ToMaginTop .4s cubic-bezier(0.08, 0.82, 0.17, 1);
|
||||
}
|
||||
.margin-top-close{
|
||||
display: block !important;
|
||||
animation: FromMaginTop .4s cubic-bezier(0.6, 0.04, 0.98, 0.34);
|
||||
-webkit-animation: FromMaginTop .4s cubic-bezier(0.6, 0.04, 0.98, 0.34);
|
||||
}
|
||||
|
||||
/*********动画***********/
|
||||
@keyframes ToScale {
|
||||
0%{
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
}
|
||||
100%{
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
@keyframes FromScale {
|
||||
0%{
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
100%{
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
}
|
||||
}
|
||||
@keyframes ToMaginTop {
|
||||
0%{
|
||||
opacity: 0;
|
||||
margin-top: -100%;
|
||||
}
|
||||
100%{
|
||||
opacity: 1;
|
||||
margin-top: 0%;
|
||||
}
|
||||
}
|
||||
@keyframes FromMaginTop {
|
||||
0%{
|
||||
opacity: 1;
|
||||
margin-top: 0%;
|
||||
}
|
||||
100%{
|
||||
opacity: 0;
|
||||
margin-top: -100%;
|
||||
}
|
||||
}
|
622
static/motion.js
Normal file
622
static/motion.js
Normal file
@ -0,0 +1,622 @@
|
||||
/**
|
||||
* Created by jljsj on 15/6/24.
|
||||
*/
|
||||
$(function (){
|
||||
var $S=function(typename){
|
||||
if(typename.indexOf("<")>=0){
|
||||
var node=$(typename);
|
||||
var node_m=$(document.createElementNS("http://www.w3.org/2000/svg",node[0].tagName.toLowerCase()));
|
||||
//var node_b=typename.replace(/<[^\s]*|[>,/>]*/gi,"");
|
||||
for(var i=0;i<node[0].attributes.length;i++){
|
||||
node_m.attr(node[0].attributes[i].name,node[0].attributes[i].value);
|
||||
}
|
||||
node_m.html(node.html());
|
||||
return node_m
|
||||
}
|
||||
return $(document.createElementNS("http://www.w3.org/2000/svg",typename))
|
||||
};
|
||||
var SVG=(function () {
|
||||
var s_node=function (s){
|
||||
if(s){
|
||||
this.node=$S(s);
|
||||
}
|
||||
};
|
||||
var n=s_node.prototype={
|
||||
_x:0,
|
||||
_y:0,
|
||||
_scaleX:1,
|
||||
_scaleY:1,
|
||||
_rotation:0,
|
||||
_skewX:0,
|
||||
_skewY:0,
|
||||
set id(id){this.attr("id",id)},
|
||||
get id(){return this.attr("id")},
|
||||
set x(x){this.setTransform(x,this._y,this._scaleX,this._scaleY,this._rotation,this._skewX,this._skewY);},
|
||||
get x(){return this._x},
|
||||
set y(y){this.setTransform(this._x,y,this._scaleX,this._scaleY,this._rotation,this._skewX,this._skewY);},
|
||||
get y(){return this._y},
|
||||
set scale(x){this.setTransform(this._x,this._y,x,x,this._rotation,this._skewX,this._skewY);},
|
||||
get scale(){return this._scaleX==this._scaleY?this._scaleX:{scaleX:this._scaleX,scaleY:this._scaleY}},
|
||||
set scaleX(x){this.setTransform(this._x,this._y,x,this._scaleY,this._rotation,this._skewX,this._skewY);},
|
||||
get scaleX(){return this._scaleX},
|
||||
set scaleY(y){this.setTransform(this._x,this._y,this._scaleX,y,this._rotation,this._skewX,this._skewY);},
|
||||
get scaleY(){return this._scaleY},
|
||||
set rotation(r){this.setTransform(this._x,this._y,this._scaleX,this._scaleY,r,this._skewX,this._skewY);},
|
||||
get rotation(){return this._rotation},
|
||||
set skewX(x){this.setTransform(this._x,this._y,this._scaleX,this._scaleY,this._rotation,x,this._skewY);},
|
||||
get skewX(){return this._skewX},
|
||||
set skewY(y){this.setTransform(this._x,this._y,this._scaleX,this._scaleY,this._rotation,this._skewX,y);},
|
||||
get skewY(){return this._skewY},
|
||||
set alpha(a){this.attr("opacity", a.toString())},
|
||||
get alpha(){return Number(this.attr("opacity"))>=0?Number(this.attr("opacity")):1},
|
||||
set mouseEnabled(Bool){
|
||||
if(Bool){
|
||||
this.attr("cursor","pointer")
|
||||
}
|
||||
},
|
||||
get mouseEnabled(){
|
||||
return !!this.attr("cursor");
|
||||
}
|
||||
};
|
||||
n.attr=function (o,d){
|
||||
return d?this.node.attr(o,d):this.node.attr(o)
|
||||
};
|
||||
n.css=function (o,d){
|
||||
return d?this.node.css(o,d):this.node.attr(o);
|
||||
};
|
||||
n.children=function (){
|
||||
return this.node.children()
|
||||
};
|
||||
n.find=function (s){
|
||||
return this.node.find(s);
|
||||
}
|
||||
n.addEventListener=function (event,func){
|
||||
return this.node.bind(event,func);
|
||||
};
|
||||
n.bind=function (event,func){
|
||||
return this.node.bind(event,func);
|
||||
};
|
||||
n.setTransform=function(x,y,scaleX,scaleY,rotation,skewX,skewY){
|
||||
var x=x||0,y=y||0,scaleX=scaleX>=0?scaleX:1,scaleY=scaleY>=0?scaleY:1,
|
||||
rotation=rotation||0,skewX=skewX||0,skewY=skewY||0;
|
||||
this._x=x,this._y=y,this._scaleX=scaleX,this._scaleY=scaleY,
|
||||
this._rotation=rotation,this._skewX=skewX,this._skewY=skewY;
|
||||
var DEG_TO_RAD=Math.PI/180;
|
||||
var Matrix={
|
||||
a:1,b:0,c:0,d:1,tx:0,ty:0,
|
||||
initialize:function(a, b,c,d,tx,ty){
|
||||
var a1 = this.a;
|
||||
var b1 = this.b;
|
||||
var c1 = this.c;
|
||||
var d1 = this.d;
|
||||
this.a = a*a1+b*c1;
|
||||
this.b = a*b1+b*d1;
|
||||
this.c = c*a1+d*c1;
|
||||
this.d = c*b1+d*d1;
|
||||
this.tx = tx*a1+ty*c1+this.tx;
|
||||
this.ty = tx*b1+ty*d1+this.ty;
|
||||
return this
|
||||
}
|
||||
};
|
||||
if(rotation%360){
|
||||
var r=rotation*DEG_TO_RAD;
|
||||
var cos = Math.cos(r);
|
||||
var sin = Math.sin(r);
|
||||
}else {
|
||||
cos = 1;
|
||||
sin = 0;
|
||||
}
|
||||
var t=Matrix;
|
||||
if (skewX || skewY) {
|
||||
skewX = skewX*DEG_TO_RAD||0;
|
||||
skewY = skewY*DEG_TO_RAD||0;
|
||||
t.initialize(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);
|
||||
t.initialize(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);
|
||||
} else {
|
||||
t.initialize(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);
|
||||
}
|
||||
var val="matrix("+t.a+","+ t.b+","+ t.c+","+ t.d+","+ t.tx+","+ t.ty+")";
|
||||
this.attr("transform",val)
|
||||
};
|
||||
n.addChild=function (elem){
|
||||
if(elem.node) this.node.append(elem.node);
|
||||
else this.node.append(elem);
|
||||
};
|
||||
n.clear=function (index){
|
||||
if(index>=0){
|
||||
this.node.children().eq(index).remove();
|
||||
return
|
||||
}
|
||||
return this.node.children().remove();
|
||||
};
|
||||
n.setFilter=function (dom){
|
||||
this.attr("filter","url(#"+dom.attr("id")+")")
|
||||
};
|
||||
n.setClipPath=function(dom){
|
||||
this.attr("clip-path","url(#"+dom.attr("id")+")");
|
||||
};
|
||||
var SectorStr=function (point,r,angle,startAngle,inr){
|
||||
angle=(Math.abs(angle) > 360) ? 360 : angle;
|
||||
var flag=angle>180?1:0;
|
||||
startAngle = startAngle * Math.PI / 180;
|
||||
var str="";//"M"+point.x+" "+point.y;
|
||||
str+=" M"+(point.x + r * Math.cos(startAngle))+" "+(point.y+r * Math.sin(startAngle))
|
||||
var angleA,cx,cy;
|
||||
if(angle>=360){
|
||||
angleA=angle/2;
|
||||
angleA=angleA*Math.PI/180;
|
||||
angleA=angleA+startAngle;
|
||||
for(var i=0;i<2;i++){
|
||||
cx=point.x+r*Math.cos(angleA+i*Math.PI);
|
||||
cy=point.y+r*Math.sin(angleA+i*Math.PI);
|
||||
str+="A"+r+" "+r+" 0 1 1 "+cx+" "+cy;
|
||||
}
|
||||
str+=" Z";
|
||||
return str;
|
||||
}
|
||||
angle=angle*Math.PI/180;
|
||||
angleA=angle+startAngle;
|
||||
|
||||
cx = point.x + r * Math.cos(angleA);
|
||||
cy = point.y + r * Math.sin(angleA);
|
||||
str+="A"+r+" "+r+" 0 "+flag+" 1 "+cx+" "+cy;
|
||||
if(angle<Math.PI*2){
|
||||
str+=" L"+point.x+" "+point.y
|
||||
}
|
||||
//画内圆;
|
||||
if(inr){
|
||||
cx = point.x + inr * Math.cos(angleA);
|
||||
cy = point.y + inr * Math.sin(angleA);
|
||||
str+="L"+cx+" "+cy;
|
||||
cx=point.x + inr * Math.cos(startAngle);
|
||||
cy=point.y+ inr * Math.sin(startAngle);
|
||||
str+="A"+inr+" "+inr+" 0 "+flag+" 0 "+cx+" "+cy;
|
||||
}
|
||||
str+=" Z";
|
||||
return str
|
||||
};
|
||||
var Sprite=function (s){
|
||||
if(s){
|
||||
this.node=$S(s);
|
||||
}
|
||||
};
|
||||
var sp=Sprite.prototype=new s_node();
|
||||
|
||||
sp.drawRect=function (obj){
|
||||
var t=new SVG.Sprite("rect");
|
||||
t.attr(obj).appendTo(this.node);
|
||||
return t
|
||||
};
|
||||
sp.drawCirc=function (obj){
|
||||
var t=new SVG.Sprite("circle");
|
||||
t.attr(obj).appendTo(this.node);
|
||||
return t
|
||||
};
|
||||
sp.drawPolygon=function (obj){
|
||||
var t=new SVG.Sprite("polygon");
|
||||
t.attr(obj).appendTo(this.node);
|
||||
return t
|
||||
};
|
||||
sp.drawPath=function (obj){
|
||||
var t=new SVG.Sprite("path");
|
||||
t.attr(obj).appendTo(this.node);
|
||||
return t
|
||||
};
|
||||
sp.drawEllipse=function (obj){
|
||||
var t=new SVG.Sprite("ellipse");
|
||||
t.attr(obj).appendTo(this.node);
|
||||
return t
|
||||
};
|
||||
sp.drawSector=function (point,r,angle,startAngle,color,line,lineColor){
|
||||
var str=SectorStr(point,r,angle,startAngle,1);
|
||||
var m=$S("path").attr("fill",color);
|
||||
if(line){
|
||||
m.attr({stroke:lineColor,"stroke-width":line});
|
||||
}
|
||||
m.attr("d",str).appendTo(this.node);
|
||||
return m
|
||||
};
|
||||
sp.drawAnnular=function (point,r,inr,angle,startAngle,color,line,lineColor){
|
||||
var str=SectorStr(point,r,angle,startAngle,inr);
|
||||
var m=$S("path").attr("fill",color);
|
||||
if(line){
|
||||
m.attr({stroke:lineColor,"stroke-width":line});
|
||||
}
|
||||
m.attr("d",str).appendTo(this.node);
|
||||
return m
|
||||
};
|
||||
|
||||
function svg(id){
|
||||
this.initialize(id);
|
||||
}
|
||||
var s=svg.prototype=new Sprite();
|
||||
s.initialize=function (id){
|
||||
this.node=$S("svg");
|
||||
this.attr({"width":"100%","height":"100%"});
|
||||
this.defs=new Sprite("defs");
|
||||
this.addChild(this.defs);
|
||||
$(id).append(this.node);
|
||||
};
|
||||
var filter={
|
||||
blur : function (x, y) {
|
||||
if (x == null) {
|
||||
x = 2;
|
||||
}
|
||||
var def = y == null ? x : [x, y];
|
||||
var t=document.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");
|
||||
t.setAttribute("stdDeviation",def);
|
||||
var filter=$S("filter");
|
||||
filter.attr({x:"-50%",y:"-50%","width":"200%","height":"200%"});
|
||||
filter.append(t);
|
||||
Object.defineProperty(filter,"id",{
|
||||
get:function (){
|
||||
return filter.attr("id");
|
||||
},
|
||||
set:function (id){
|
||||
filter.attr("id",id);
|
||||
}
|
||||
});
|
||||
return filter
|
||||
},
|
||||
goo:function (blur){
|
||||
var t=document.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");
|
||||
t.setAttribute("in","SourceGraphic");
|
||||
t.setAttribute("stdDeviation",blur);
|
||||
t.setAttribute("result","blur");
|
||||
var matrix=document.createElementNS("http://www.w3.org/2000/svg","feColorMatrix");
|
||||
matrix.setAttribute("in","blur");
|
||||
matrix.setAttribute("mode","matrix");
|
||||
matrix.setAttribute("values","1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -6");
|
||||
matrix.setAttribute("result","goo");
|
||||
var com=document.createElementNS("http://www.w3.org/2000/svg","feComposite");
|
||||
com.setAttribute("in","SourceGraphic");
|
||||
com.setAttribute("in2","goo");
|
||||
com.setAttribute("operator","atop");
|
||||
var filter=$S("filter");
|
||||
filter.append([t,matrix,com]);
|
||||
return filter
|
||||
},
|
||||
mask:function (tb,obj){
|
||||
var t=$S(tb);
|
||||
t.attr(obj);
|
||||
var cp=$S("clipPath");
|
||||
cp.append(t);
|
||||
Object.defineProperty(cp,"id",{
|
||||
get:function (){
|
||||
return cp.attr("id");
|
||||
},
|
||||
set:function (id){
|
||||
cp.attr("id",id);
|
||||
}
|
||||
});
|
||||
//var cp=document.createElementNS("http://www.w3.org/2000/svg","clipPath");//$S("clippath");
|
||||
//cp.appendChild(t[0]);
|
||||
//Object.defineProperty(cp,"id",{
|
||||
// get:function (){
|
||||
// return cp.getAttribute("id");
|
||||
// },
|
||||
// set:function (id){
|
||||
// cp.setAttribute("id",id);
|
||||
// }
|
||||
//});
|
||||
return cp;
|
||||
}
|
||||
};
|
||||
var text=function (_text,_data){
|
||||
this.node=$S("text");
|
||||
this.node.text(_text);
|
||||
if(_data){
|
||||
this.node.attr(_data);
|
||||
}
|
||||
};
|
||||
var t=text.prototype=new s_node;
|
||||
t.tspan=function (_text,_data){
|
||||
this.node=$S("tspan");
|
||||
this.node.text(_text);
|
||||
if(_data){
|
||||
this.node.attr(_data);
|
||||
}
|
||||
};
|
||||
var ts= t.tspan.prototype=new s_node();
|
||||
|
||||
svg.SectorStr=SectorStr;
|
||||
svg.filter=filter;
|
||||
svg.Sprite=Sprite;
|
||||
svg.Text=text;
|
||||
svg.Text.tSpan= t.tspan;
|
||||
return svg
|
||||
}());
|
||||
var Point=function (x,y){
|
||||
this.x=x;
|
||||
this.y=y;
|
||||
return this;
|
||||
};
|
||||
var T=TweenMax;
|
||||
var newMotion=function (id,obj){
|
||||
if(!id||!obj){
|
||||
throw new Error("数据错误");
|
||||
}
|
||||
var self=this;
|
||||
self.box=$(id);
|
||||
self.box.css({"width":800});
|
||||
if(self.box.width()<500){
|
||||
self.box.css("height",600);
|
||||
}else{
|
||||
self.box.css("height",300)
|
||||
}
|
||||
self.data=obj;
|
||||
self.svg=new SVG(id);
|
||||
self.svg.css("background-color","#f3f3f3");
|
||||
self.w=self.box.width();
|
||||
self.h=self.box.height();
|
||||
self.tweenArr=[];
|
||||
self.t_time=1;
|
||||
self.d_time=.5;
|
||||
self.tweenAllTime=2.5;
|
||||
|
||||
self.addElement();
|
||||
|
||||
function resize(e){
|
||||
self.windowResize(self)
|
||||
}
|
||||
resize();
|
||||
$(window).bind("resize", resize);
|
||||
};
|
||||
var nm=newMotion.prototype={
|
||||
};
|
||||
nm.windowResize=function (self){
|
||||
var s=self.box.parent().width()/800>1?1:self.box.parent().width()/800;
|
||||
self.box.css({"transform": "scale("+s+")","transform-origin":"0 0"});
|
||||
};
|
||||
nm.addElement=function (){
|
||||
var self=this;
|
||||
//绘制坐标系统;
|
||||
self.coords=new SVG.Sprite("g");
|
||||
self.svg.addChild(self.coords);
|
||||
var coordsStr="M80 50 L80 250 L480 250";
|
||||
self.coords.drawPath({d:coordsStr,fill:"none","stroke-width":2,stroke:"#d9d9d9"});
|
||||
var timerTxt=new SVG.Text("timer",{fill:"#999"});
|
||||
self.coords.addChild(timerTxt);
|
||||
timerTxt.x=240;
|
||||
timerTxt.y=275;
|
||||
var yaxis=new SVG.Text("Y-axis",{fill:"#999"});
|
||||
yaxis.width=20;
|
||||
yaxis.x=20;
|
||||
yaxis.y=150;
|
||||
self.coords.addChild(yaxis);
|
||||
//动画示例元素;
|
||||
self.tweenMc=new SVG.Sprite("g");
|
||||
if(self.data.mask){
|
||||
var mask=new SVG.filter.mask("rect",{width:260,height:200});
|
||||
mask.id="mask";
|
||||
self.svg.defs.addChild(mask);
|
||||
self.tweenMc.setClipPath(mask);
|
||||
}
|
||||
|
||||
self.svg.addChild(self.tweenMc);
|
||||
self.tweenMc.x=500;
|
||||
self.tweenMc.y=50;
|
||||
//坐标线;
|
||||
/**
|
||||
* 以三次贝塞尔曲线
|
||||
* 时间长4秒
|
||||
* -分三段-
|
||||
* 前缓动--linear--后缓动
|
||||
* 1--.5--1
|
||||
*/
|
||||
var c_w=360,c_h=180,
|
||||
c_x=100,c_y=250,ct_y=70,
|
||||
t_w=c_w/ self.tweenAllTime,tt_w=t_w+c_x,d_w=(self.t_time+self.d_time)/self.tweenAllTime;
|
||||
|
||||
for(var i=0;i<self.data.lineData.length;i++){
|
||||
var tb=new SVG.Sprite("g");
|
||||
self.coords.addChild(tb);
|
||||
var str="M80 250";
|
||||
var open=self.data.lineData[i].open;
|
||||
if(open.length!==4&&open.length!==0){
|
||||
throw new Error(open+"数据错误");
|
||||
}
|
||||
if(open.length!==0){
|
||||
str+="L100 250"+"C"+(open[0]*t_w+c_x)+","+(c_y-open[1]*c_h)+" "+(open[2]*t_w+c_x)+","+(c_y-open[3]*c_h)+" "+tt_w+","+ct_y
|
||||
}else{
|
||||
str+="L100 250"+"L"+tt_w+","+ct_y;
|
||||
}
|
||||
tb.drawPath({d:str,fill:"none","stroke-width":2,stroke:self.data.lineData[i].stroke||"#999","stroke-dasharray":"0 100%"});
|
||||
|
||||
var e_x=c_w*d_w+c_x;
|
||||
str="M"+tt_w+","+ct_y+"L"+e_x+","+ct_y;
|
||||
tb.drawPath({d:str,fill:"none","stroke-width":2,stroke:self.data.lineData[i].stroke||"#999","stroke-dasharray":"0 100%"});
|
||||
var end=self.data.lineData[i].end;
|
||||
if(end.length!==4&&end.length!==0){
|
||||
throw new Error(end+"数据错误");
|
||||
}
|
||||
str="M"+e_x+","+ct_y;
|
||||
if(end.length!==0){
|
||||
str+="C"+(end[0]*t_w+e_x)+","+(end[1]*c_h+ct_y)+" "+(end[2]*t_w+e_x)+","+(end[3]*c_h+ct_y)+" "+(c_w+c_x-20)+","+c_y+"L"+(c_w+c_x)+","+c_y
|
||||
}else{
|
||||
if(self.data.lineData[i].endEaseName!=="null"){
|
||||
str+="L"+(c_w+c_x-20)+","+c_y+"L"+(c_w+c_x)+","+c_y;
|
||||
}else{
|
||||
str+="L"+e_x+","+ct_y;
|
||||
}
|
||||
}
|
||||
tb.drawPath({d:str,fill:"none","stroke-width":2,stroke:self.data.lineData[i].stroke||"#999","stroke-dasharray":"0 100%"});
|
||||
|
||||
//元素插入盒子里;
|
||||
var circ=new SVG.Sprite("circle");
|
||||
circ.attr({"r":10,fill:"none","stroke-width":6,stroke:self.data.lineData[i].stroke||"#999"});
|
||||
self.tweenMc.addChild(circ);
|
||||
if(self.data.exposure=="left"||!self.data.exposure){
|
||||
circ.x=self.data.mask?-20:20;
|
||||
circ.y=50+i*110//self.data.mask?240:180;
|
||||
}else if(self.data.exposure=="top"){
|
||||
circ.x=100+i*100//self.data.mask?-20:20;
|
||||
circ.y=self.data.mask?-20:20;
|
||||
}else if(self.data.exposure=="right"){
|
||||
circ.x=self.data.mask?280:220;
|
||||
circ.y=50+i*110//self.data.mask?240:180;
|
||||
}else{
|
||||
circ.x=100+i*100//self.data.mask?-20:20;
|
||||
circ.y=self.data.mask?240:180;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//建播放按钮;
|
||||
self.playBox=new SVG.Sprite("g");
|
||||
self.playBox.mouseEnabled=true;
|
||||
self.svg.addChild(self.playBox);
|
||||
self.playBox.drawRect({width:"100%",height:"100%",fill:"rgba(0,0,0,.35)"});
|
||||
self.playBtn=new SVG.Sprite("g");
|
||||
self.playBox.addChild(self.playBtn);
|
||||
self.playBtn.drawCirc({r:30,fill:"rgba(255,255,255,1)"});
|
||||
self.playBtn.x=self.w/2;
|
||||
self.playBtn.y=self.h/2;
|
||||
var playPoints={
|
||||
play:"M-10 -15 L15 0 L-10 15 L-10 0Z M-10 -15 L15 0 L-10 15 L-10 0Z",
|
||||
pause:"M-12 -15 L-3 -15 L-3 15 L-12 15Z M3 -15 L12 -15 L12 15 L3 15Z"
|
||||
};
|
||||
var shanjiao=self.playBtn.drawPath({d:playPoints.play,fill:"#999"});
|
||||
var bBool=false;
|
||||
var animate_p3 = function(p,_arr) {
|
||||
var a_arr=[];
|
||||
for(var i=0;i<_arr.length;i++){
|
||||
a_arr.push(_arr[i].x,_arr[i].y)
|
||||
}
|
||||
for(var i=0;i<a_arr.length;i++){
|
||||
if(i==0||i==8){
|
||||
a_arr[i]="M"+a_arr[i];
|
||||
}else if(i==2||i==4||i==6||i==12||i==14){
|
||||
a_arr[i]="L"+a_arr[i];
|
||||
}else if(i==7||i==15){
|
||||
a_arr[i]=a_arr[i]+"Z";
|
||||
}
|
||||
}
|
||||
p.attr({
|
||||
d: a_arr.join().replace(/,/g," ")
|
||||
});
|
||||
|
||||
};
|
||||
function twennBtn(p,arr,c_arr){
|
||||
for(var i=0;i<arr.length;i++){
|
||||
T.killTweensOf(arr[i]);
|
||||
T.to(arr[i],.6,{x:c_arr[i].x ,y:c_arr[i].y ,delay:Math.random() *.2,onUpdate:animate_p3,onUpdateParams:[p,arr],ease:Elastic.easeOut})
|
||||
}
|
||||
}
|
||||
self.playBox.addEventListener("click",function (e){
|
||||
var _a= playPoints.play.replace( /[MLZ]/g,"").split(" ");
|
||||
var _b= playPoints.pause.replace( /[MLZ]/g,"").split(" ");
|
||||
var _arr=[],_barr=[];
|
||||
for(var i=0;i<_a.length;i+=2){
|
||||
var a={},b={};
|
||||
a.x=_a[i];
|
||||
a.y=_a[i+1];
|
||||
b.x=_b[i];
|
||||
b.y=_b[i+1];
|
||||
_arr.push(a);
|
||||
_barr.push(b);
|
||||
}
|
||||
if(!bBool){
|
||||
twennBtn(shanjiao,_arr,_barr);
|
||||
T.to(self.playBox,.5,{delay:.3,alpha:0,onComplete:self.strat,onCompleteParams:[self]});
|
||||
bBool=true;
|
||||
}else{
|
||||
twennBtn(shanjiao,_barr,_arr);
|
||||
T.to(self.playBox,.5,{alpha:1,onStart:self.pause,onStartParams:[self]});
|
||||
bBool=false
|
||||
}
|
||||
});
|
||||
};
|
||||
nm.pause=function (self){
|
||||
for(var i=0;i<self.tweenArr.length;i++){
|
||||
var tl=self.tweenArr[i];
|
||||
tl.pause();
|
||||
}
|
||||
};
|
||||
nm.resume=function (self){
|
||||
for(var i=0;i<self.tweenArr.length;i++){
|
||||
var tl=self.tweenArr[i];
|
||||
tl.resume();
|
||||
}
|
||||
};
|
||||
nm.strat=function (self){
|
||||
if(self.tweenArr.length){
|
||||
self.resume(self);
|
||||
return
|
||||
}
|
||||
var lineBox=self.coords.find("g");
|
||||
for(var i=0;i<lineBox.length;i++){
|
||||
var m=lineBox.eq(i);
|
||||
var tl=new TimelineMax({repeat:-1,repeatDelay:1});
|
||||
self.tweenArr.push(tl);
|
||||
for(var ii=0;ii< m.find("path").length;ii++){
|
||||
var p=m.find("path").eq(ii);
|
||||
var lineLength=p[0].getTotalLength();
|
||||
var time= 1,_ease=Power2.easeInOut;
|
||||
|
||||
if(ii==0){
|
||||
time= self.t_time;
|
||||
_ease=EaseLookup.find(self.data.lineData[i].openEaseName);
|
||||
}
|
||||
else if(ii==1){
|
||||
time= self.d_time;
|
||||
_ease=Power0.easeNone;
|
||||
}
|
||||
else {
|
||||
time= self.t_time;
|
||||
_ease=EaseLookup.find(self.data.lineData[i].endEaseName);
|
||||
}
|
||||
if(!self.data.lineData[i].open.length){
|
||||
_ease=Linear.easeNone;
|
||||
}
|
||||
tl.add(T.to(p,time,{"stroke-dasharray":lineLength+" 100%",ease:_ease}))
|
||||
//tl.to(p,time,{"stroke-dasharray":"100% 100%",ease: Power2.easeInOut})
|
||||
}
|
||||
//circ动画
|
||||
var ctl=new TimelineMax({repeat:-1,repeatDelay:1});
|
||||
var ciric=self.tweenMc.children().eq(i);
|
||||
|
||||
|
||||
var oease=self.data.lineData[i].open.length?EaseLookup.find(self.data.lineData[i].openEaseName):Power0.easeNone,
|
||||
eease=self.data.lineData[i].end.length?EaseLookup.find(self.data.lineData[i].endEaseName):Power0.easeNone;
|
||||
//console.log(self.data.lineData[i].open,oease,eease,i);
|
||||
//if(self.data.lineData[i].openEaseName=="Bounce.easeOut")
|
||||
if(self.data.lineData[i].openEaseName&&self.data.lineData[i].openEaseName.indexOf("Bounce")>=0){
|
||||
if(self.data.lineData[i].openEaseName.indexOf("InOut")>=0){
|
||||
oease=Bounce.easeInOut
|
||||
}else if(self.data.lineData[i].openEaseName.indexOf("In")>=0){
|
||||
oease=Bounce.easeIn
|
||||
}else{
|
||||
oease=Bounce.easeOut
|
||||
}
|
||||
}
|
||||
var cx={},_x={};
|
||||
if(self.data.exposure=="left"||!self.data.exposure){
|
||||
_x={x:240};
|
||||
cx={x:self.data.mask?-20:20};
|
||||
}else if(self.data.exposure=="top"){
|
||||
_x={y:180};
|
||||
cx={y:self.data.mask?-20:20};
|
||||
}else if(self.data.exposure=="right"){
|
||||
_x={x:20};
|
||||
cx={x:self.data.mask?280:220};
|
||||
}else{
|
||||
_x={y:20};
|
||||
cx={y:self.data.mask?240:180};
|
||||
}
|
||||
if(self.data.lineData[i].endEaseName!=="null"){
|
||||
_x.ease=oease,cx.ease=eease,cx.delay=self.d_time;
|
||||
}else{
|
||||
var t=cx;
|
||||
cx={};
|
||||
cx.startAt= t;
|
||||
cx.delay=self.d_time;
|
||||
_x.ease=oease,cx.ease=eease;
|
||||
}
|
||||
ctl.to(ciric,self.t_time,_x).to(ciric,self.t_time,cx);
|
||||
self.tweenArr.push(ctl);
|
||||
}
|
||||
};
|
||||
window.Motion=newMotion;
|
||||
|
||||
});
|
101
static/motionDome.css
Normal file
101
static/motionDome.css
Normal file
@ -0,0 +1,101 @@
|
||||
.ant-btn-domebox{
|
||||
background-color: #f3f3f3;
|
||||
width:100%;
|
||||
text-align:center;
|
||||
overflow:hidden;
|
||||
padding: 20px;
|
||||
min-height: 236px;
|
||||
}
|
||||
.ant-anim-box{
|
||||
width: 800px;
|
||||
height: 300px;
|
||||
transform: scale(1);
|
||||
transform-origin: 0px 0px 0px;
|
||||
background-color: #efefef;
|
||||
position: relative;
|
||||
}
|
||||
.ant-btn{
|
||||
margin:10px auto;
|
||||
}
|
||||
.ant-btn-lq{
|
||||
display:block;
|
||||
position:absolute;
|
||||
opacity:.2;
|
||||
transform:scale(0);
|
||||
-webkit-transition:scale(0);
|
||||
transition: transform .4s cubic-bezier(0.455, 0.03, 0.515, 0.955);
|
||||
-webkit-transition: -webkit-transform .4s cubic-bezier(0.455, 0.03, 0.515, 0.955);
|
||||
}
|
||||
.anticon-loading{
|
||||
position:absolute;
|
||||
left:50%;
|
||||
margin-left:-7px;
|
||||
opacity:0;
|
||||
transform: scale(0);
|
||||
-webkit-transform:scale(0);
|
||||
}
|
||||
.ant-btn-load,.ant-btn-load span,.ant-btn-load text{
|
||||
transition: all .4s cubic-bezier(0.455, 0.03, 0.515, 0.955);
|
||||
-webkit-transition: all .4s cubic-bezier(0.455, 0.03, 0.515, 0.955);
|
||||
}
|
||||
.anticon-loading:before {
|
||||
font-size:18px
|
||||
}
|
||||
.ant-btn-reload{
|
||||
display: block;
|
||||
}
|
||||
.ant-btn-reload text{
|
||||
display: block;
|
||||
position: absolute;
|
||||
top:100%;
|
||||
left:50%;
|
||||
margin-left: -12px;
|
||||
}
|
||||
.ant-btn-reload span,.ant-btn-reload text{
|
||||
transition: all .4s cubic-bezier(0.455, 0.03, 0.515, 0.955);
|
||||
-webkit-transition: all .4s cubic-bezier(0.455, 0.03, 0.515, 0.955);
|
||||
}
|
||||
.anticon-reload{
|
||||
font-size: 16px !important;
|
||||
}
|
||||
.ant-btn-reload:hover text{
|
||||
top:50%;
|
||||
margin-top: -9px;
|
||||
}
|
||||
.ant-btn-reload:hover span{
|
||||
transform: translateY(-22px);
|
||||
}
|
||||
|
||||
.ant-anim-dometip{
|
||||
position: absolute;
|
||||
background: #fff;
|
||||
box-shadow: 2px 2px 5px rgba(0,0,0,.15);
|
||||
/*transform: scale(0);
|
||||
-webkit-transform: scale(0);*/
|
||||
}
|
||||
.ant-anim-dometip ul{
|
||||
padding: 20px;
|
||||
}
|
||||
.ant-anim-topArrow:before{
|
||||
content: " ";
|
||||
display: block;
|
||||
position: absolute;
|
||||
border-left: 10px solid transparent;
|
||||
border-right: 10px solid transparent;
|
||||
border-bottom: 10px solid white;
|
||||
right: 5px;
|
||||
top:-10px
|
||||
}
|
||||
.ant-dropdown-wrap{
|
||||
text-align: left;
|
||||
}
|
||||
.ant-dropdown-wrap .ant-btn{
|
||||
margin-bottom: auto;
|
||||
}
|
||||
.ant-dropdown-wrap .ant-dropdown{
|
||||
left:auto;
|
||||
top:auto;
|
||||
display: none;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
111
static/motionDome.js
Normal file
111
static/motionDome.js
Normal file
@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Created by jljsj on 15/6/30.
|
||||
*/
|
||||
$(function (){
|
||||
var animBtnDome={
|
||||
animStr:'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend',
|
||||
init:function() {
|
||||
var self=this;
|
||||
self.body=$("body");
|
||||
self.btn=$(".ant-btn-ripple");
|
||||
//$(".ant-btn-lq").bind("click",function (le){
|
||||
// le.stopPropagation();
|
||||
//});
|
||||
|
||||
//涟漪效果
|
||||
self.btn.bind("mousedown",function (e){
|
||||
//console.log(e)
|
||||
//var _x= e.offsetX,_y= e.offsetY;
|
||||
var __x=$(this).offset().left,__y=$(this).offset().top,
|
||||
_x= e.pageX-__x,_y= e.pageY-__y;
|
||||
var lq=$("<em class='ant-btn-lq'></em>").prependTo(this);
|
||||
var _w=this.offsetWidth,_h=this.offsetHeight;
|
||||
lq.removeAttr("style").css({width:_w,height:_w,"border-radius":_w/2,left:_x-_w/2,top:_y-_w/2});
|
||||
if($(this).attr("class").indexOf("ant-btn-primary")>=0||$(this).attr("class").indexOf("ant-btn-ghost")>=0){
|
||||
lq.css("background-color","#fff");
|
||||
}else{
|
||||
lq.css("background-color","#999");
|
||||
}
|
||||
var s=0;
|
||||
//if(_h>=_w){
|
||||
// s=_y/_h*2<1?2-_y/_h*2:_y/_h*2;
|
||||
//}
|
||||
|
||||
var _sx=_x/_w* 2,_sy=_y/_h*2;
|
||||
if(_sx>1&&_sy>1){
|
||||
s=_sx>_sy?_sx:_sy;
|
||||
}else if(_sx>1||_sy>1){
|
||||
_sx=_sx<1?2-_sx:_sx;
|
||||
_sy=_sy<1?2-_sy:_sy;
|
||||
s=_sx>_sy?_sx:_sy;
|
||||
}else {
|
||||
s=2-_sx>2-_sy?2-_sx:2-_sy;
|
||||
}
|
||||
s=s+.3;
|
||||
lq.css("transform","scale("+s+")")
|
||||
|
||||
});
|
||||
function mousee_up(e){
|
||||
var lq=$(this).find(".ant-btn-lq");
|
||||
lq.delay(300).animate({opacity:0},300,function (){
|
||||
lq.remove();
|
||||
})
|
||||
}
|
||||
self.btn.bind("mouseout",mousee_up);
|
||||
self.btn.bind("mouseup",mousee_up);
|
||||
|
||||
//加载按钮
|
||||
self.loadBtn=$(".ant-btn-load");
|
||||
self.loadBtn.bind("click",function (e){
|
||||
var m=$(this);
|
||||
m.find("text").css({"opacity":"0","transform": "scale(2)"});
|
||||
m.find("span").css({"opacity":1,"transform": "scale(1)"});
|
||||
setTimeout(function (){
|
||||
m.find("text").removeAttr("style");
|
||||
m.find("span").removeAttr("style")
|
||||
},4000)
|
||||
});
|
||||
|
||||
//替换
|
||||
function reqClass(m,_class,call){
|
||||
if(m.attr("class").indexOf(_class+"-open")>=0){
|
||||
m.removeClass(_class+"-open").addClass(_class+"-close").one(self.animStr,function (){
|
||||
m.removeClass(_class+"-close");
|
||||
if(typeof call=="function"){
|
||||
call()
|
||||
}
|
||||
})
|
||||
}else{
|
||||
m.addClass(_class+"-open");
|
||||
}
|
||||
}
|
||||
|
||||
//icon的下拉演示
|
||||
self.listTip=$(".ant-btn-listtip");
|
||||
self.listTip.bind("click",function (e){
|
||||
var m=$(this);
|
||||
var tip=$("#"+m.attr("data-id"));
|
||||
reqClass(tip,"scale");
|
||||
|
||||
tip.css({left: m.position().left-tip.width()+ m.outerWidth()-2,top: m.position().top+m.outerHeight()+12})
|
||||
});
|
||||
|
||||
//dropdown演示的事件
|
||||
self.dropdown=$(".ant-dropdown-wrap");
|
||||
self.dropdown.find(".ant-btn-menu").bind("click",function (e){
|
||||
var m=$(this),p= m.parent(),d= p.find(".ant-dropdown"),
|
||||
con= d.find(".ant-dropdown-con"),str="margin-top";
|
||||
d.css({"display":"block","margin-top":2});
|
||||
reqClass(con,str,function (){
|
||||
if(con.attr("class").indexOf('margin-top')<0){
|
||||
d.css({"display":"none"})
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
};
|
||||
animBtnDome.init()
|
||||
|
||||
});
|
@ -1,3 +1,3 @@
|
||||
@import "./core/index.less";
|
||||
@import "./themes/default/index.less";
|
||||
@import "./core/index.less";
|
||||
@import "./components/index.less";
|
||||
|
@ -36,9 +36,9 @@
|
||||
@duration-1000 : 1.0s;
|
||||
@duration-1100 : 1.1s;
|
||||
@duration-1200 : 1.2s;
|
||||
@ease-out : cubic-bezier(0.25, 0.8, 0.25, 1);
|
||||
@ease-in : cubic-bezier(0.55, 0, 0.55, 0.2);
|
||||
@ease-in-out : cubic-bezier(0.35, 0, 0.25, 1);
|
||||
@ease-out : cubic-bezier(0.215, 0.61, 0.355, 1);
|
||||
@ease-in : cubic-bezier(0.55, 0.055, 0.675, 0.19);
|
||||
@ease-in-out : cubic-bezier(0.645, 0.045, 0.355, 1);
|
||||
@ease-out-back : cubic-bezier(0.18, 0.89, 0.32, 1.28);
|
||||
@ease-in-back : cubic-bezier(0.6, -0.3, 0.74, 0.05);
|
||||
@ease-in-out-back : cubic-bezier(0.68, -0.55, 0.27, 1.55);
|
||||
|
Loading…
Reference in New Issue
Block a user