/** * 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=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.css(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(angle1?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=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; var motionVideo={ init:function (){ var self=this; self.videoBox=$(".video-player"); for(var i=0;i