-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDomLine.min.js
1 lines (1 loc) · 2.5 KB
/
DomLine.min.js
1
(function(b,a){a.RenderList={renderList:[],paused:true,frameRate:30,render:function(){if(RenderList.paused){return}var c=RenderList.renderList.length;if(c==0){return}while(c--){RenderList.renderList[c].render()}setTimeout(RenderList.render,1000/RenderList.frameRate)},addItem:function(c){if(c.posInRenderList){return}RenderList.renderList.push(c);c.posInRenderList=RenderList.renderList.length-1;if(RenderList.renderList.length===1&&RenderList.paused===true){RenderList.resume()}},pause:function(){RenderList.paused=true},resume:function(){RenderList.paused=false;RenderList.render()},dequeuAll:function(){var c=RenderList.renderList.length;if(c==0){return}while(c--){this.removeItem(RenderList.renderList[c])}},removeItem:function(c){if(!c||c.posInRenderList===false){return}RenderList.renderList.splice(c.posInRenderList,1);c.posInRenderList=false}};a.DomLine=function(h,l,d){var e={autorender:false,lineWidth:1,lineColor:"black",debug:false},g={elmt:null,place:["center","center"]},f={elmt:null,place:"center-center"},i=null,c=null,k=b("body"),j=true;this.posInRenderList=false;this.render=function(){var o=g.elmt.offset(),n=f.elmt.offset(),t=o.top+(g.place[1]==="top"?0:(g.place[1]==="center"?g.elmt.outerHeight()/2:g.elmt.outerHeight())),r=n.top+(f.place[1]==="top"?0:(f.place[1]==="center"?f.elmt.outerHeight()/2:f.elmt.outerHeight())),s=o.left+(g.place[0]==="left"?0:(g.place[0]==="center"?g.elmt.outerWidth()/2:g.elmt.outerWidth())),q=n.left+(f.place[0]==="left"?0:(f.place[0]==="center"?f.elmt.outerWidth()/2:f.elmt.outerWidth()));i[0].style.left=Math.min(s,q)+"px";i[0].style.top=Math.min(t,r)+"px";var p=i[0].height=Math.max(t-r,r-t);var m=i[0].width=Math.max(s-q,q-s);c.clearRect(0,0,m,p);c.beginPath();c.lineWidth=e.lineWidth;c.moveTo(s<q?0:m,t>r?p:0);c.lineTo(s>q?0:m,t>r?0:p);c.strokeStyle=e.lineColor;c.closePath();c.stroke();return this};this.resume=function(){if(!j){throw"Canvas not Supported";return}RenderList.addItem(this);return this};this.pause=function(){if(!j){throw"Canvas not Supported";return}RenderList.removeItem(this);return this};e=b.extend({},this._settings,d);g=b.extend({},this._elmt1,h);f=b.extend({},this._elmt2,l);g.place=typeof g.place=="string"?g.place.split("-"):g.place;f.place=typeof f.place=="string"?f.place.split("-"):f.place;i=b("<canvas>",{css:{position:"absolute",display:"block"}});if(e.debug){i.css("background","red")}k.append(i);if(!(i[0].getContext&&(c=i[0].getContext("2d")))){j=false;throw"Canvas not Supported";return false}this.render();if(e.autorender){this.resume()}return this}})(jQuery,window);