UNPKG

react-raphael-scrawl

Version:
2 lines 22.3 kB
webpackJsonp([0],{0:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();n(1);var s=n(5),p=n(157),u=n(158),c=function(e){function t(){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),i(t,[{key:"handleClick",value:function(){this.refs.scrawl.clear()}},{key:"render",value:function(){return s.createElement("div",null,s.createElement("div",null,s.createElement("button",{onClick:this.handleClick.bind(this)},"清除画布")),s.createElement(u,{ref:"scrawl"}))}}]),t}(s.Component);p.render(s.createElement("div",null,s.createElement(c,null)),document.getElementById("react-container"))},1:function(e,t,n){var r=n(2);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},2:function(e,t,n){t=e.exports=n(3)(),t.push([e.id,"*{box-sizing:border-box}body{color:#666;line-height:14px}path{pointer-events:all}.react-raphael{max-width:500px;display:inline-block;vertical-align:top;float:left}",""])},3:function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t];n[2]?e.push("@media "+n[2]+"{"+n[1]+"}"):e.push(n[1])}return e.join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var r={},o=0;o<this.length;o++){var a=this[o][0];"number"==typeof a&&(r[a]=!0)}for(o=0;o<t.length;o++){var i=t[o];"number"==typeof i[0]&&r[i[0]]||(n&&!i[2]?i[2]=n:n&&(i[2]="("+i[2]+") and ("+n+")"),e.push(i))}},e}},4:function(e,t,n){function r(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=h[r.id];if(o){o.refs++;for(var a=0;a<o.parts.length;a++)o.parts[a](r.parts[a]);for(;a<r.parts.length;a++)o.parts.push(u(r.parts[a],t))}else{for(var i=[],a=0;a<r.parts.length;a++)i.push(u(r.parts[a],t));h[r.id]={id:r.id,refs:1,parts:i}}}}function o(e){for(var t=[],n={},r=0;r<e.length;r++){var o=e[r],a=o[0],i=o[1],s=o[2],p=o[3],u={css:i,media:s,sourceMap:p};n[a]?n[a].parts.push(u):t.push(n[a]={id:a,parts:[u]})}return t}function a(e,t){var n=m(),r=g[g.length-1];if("top"===e.insertAt)r?r.nextSibling?n.insertBefore(t,r.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),g.push(t);else{if("bottom"!==e.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");n.appendChild(t)}}function i(e){e.parentNode.removeChild(e);var t=g.indexOf(e);t>=0&&g.splice(t,1)}function s(e){var t=document.createElement("style");return t.type="text/css",a(e,t),t}function p(e){var t=document.createElement("link");return t.rel="stylesheet",a(e,t),t}function u(e,t){var n,r,o;if(t.singleton){var a=b++;n=v||(v=s(t)),r=c.bind(null,n,a,!1),o=c.bind(null,n,a,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=p(t),r=f.bind(null,n),o=function(){i(n),n.href&&URL.revokeObjectURL(n.href)}):(n=s(t),r=l.bind(null,n),o=function(){i(n)});return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else o()}}function c(e,t,n,r){var o=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=x(t,o);else{var a=document.createTextNode(o),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(a,i[t]):e.appendChild(a)}}function l(e,t){var n=t.css,r=t.media;if(r&&e.setAttribute("media",r),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function f(e,t){var n=t.css,r=t.sourceMap;r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var o=new Blob([n],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(o),a&&URL.revokeObjectURL(a)}var h={},y=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},d=y(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),m=y(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,b=0,g=[];e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=d()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var n=o(e);return r(n,t),function(e){for(var a=[],i=0;i<n.length;i++){var s=n[i],p=h[s.id];p.refs--,a.push(p)}if(e){var u=o(e);r(u,t)}for(var i=0;i<a.length;i++){var p=a[i];if(0===p.refs){for(var c=0;c<p.parts.length;c++)p.parts[c]();delete h[p.id]}}}};var x=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()},158:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":i(t))&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":i(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();n(159);var p=n(5),u=(n(157),n(161)),c=u.Paper,l=u.Rect,f=function(e){function t(e){r(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={loaded:!1},n}return a(t,e),s(t,[{key:"componentDidMount",value:function(){this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.setState({loaded:!0})}},{key:"handleStart",value:function(e,t,n){this.paper=this.refs.paper.getPaper();var r=this.paper.canvas.parentElement;this.offset={x:r.offsetLeft,y:r.offsetTop},this.set||(this.set=this.paper.set()),this.path=this.paper.path(),this.d=[["M",e-this.offset.x,t-this.offset.y]],this.path.attr(this.props.attr),this.path.attr({path:this.d}),this.moving=!0,this.set.push(this.path)}},{key:"handleMove",value:function(e,t,n,r,o){this.moving&&(this.d.push(["L",n-this.offset.x,r-this.offset.y]),this.path.attr({path:this.d})),this.moving=!0}},{key:"handleEnd",value:function(e){this.moving=!1}},{key:"clear",value:function(){if(this.set){for(var e=0;e<this.set.items.length;e++)this.set.items[e].remove();this.set.clear()}}},{key:"render",value:function(){var e=this.props,t=e.width,n=e.height;return p.createElement(c,{ref:"paper",width:t,height:n},p.createElement(l,{x:0,y:0,width:t,height:n,drag:{move:this.handleMove,start:this.handleStart,end:this.handleEnd}}))}}]),t}(p.Component);f.propTypes={width:p.PropTypes.number,height:p.PropTypes.number,attr:p.PropTypes.object},f.defaultProps={width:600,height:400,attr:{stroke:"#000","stroke-width":6}},e.exports=f},159:function(e,t,n){var r=n(160);"string"==typeof r&&(r=[[e.id,r,""]]);n(4)(r,{});r.locals&&(e.exports=r.locals)},160:function(e,t,n){t=e.exports=n(3)(),t.push([e.id,"rect{pointer-events:all}",""])},161:function(e,t,n){"use strict";var r=n(162),o=n(163),a=o.Paper,i=o.Set,s=o.Circle,p=o.Ellipse,u=o.Image,c=o.Path,l=o.Print,f=o.Rect,h=o.Text,y=o.Line;t.Raphael=r,t.Utils=n(164),t.Paper=a,t.Set=i,t.Element=Element,t.Circle=s,t.Ellipse=p,t.Image=u,t.Path=c,t.Print=l,t.Rect=f,t.Text=h,t.Line=y},163:function(e,t,n){"use strict";function r(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(5),c=n(157),l=n(164),f=function(e){function t(e){o(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={loaded:!1},n}return i(t,e),p(t,[{key:"componentDidMount",value:function(){var e=c.findDOMNode(this.refs.container),t=l.createPaper(e,this.props);this.paper=t,this.setState({loaded:!0,id:t.id})}},{key:"componentWillUnmount",value:function(){this.paper.remove()}},{key:"genElementsContainer",value:function(){return this.state.loaded?u.createElement("div",{className:"raphael-paper","data-id":this.state.id},this.props.children):u.createElement("div",{className:"raphael-paper"})}},{key:"getPaper",value:function(){return this.paper}},{key:"render",value:function(){var e=this.genElementsContainer(),t=this.props.container,n=t.style,o=t.className,a=r(t,["style","className"]);return u.createElement("div",{className:"react-raphael"},e,u.createElement("div",s({ref:"container",className:"paper-container "+o,style:n},a)))}}]),t}(u.Component);f.propTypes={x:u.PropTypes.number,y:u.PropTypes.number,container:u.PropTypes.object},f.defaultProps={width:100,height:100,container:{style:{},className:""}};var h=function(e){function t(e){o(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={loaded:!1},n}return i(t,e),p(t,[{key:"componentDidMount",value:function(){var e=c.findDOMNode(this.refs.root),t=e.parentElement.getAttribute("data-id"),n=l.createSet(t,this.props,this.handleLoad.bind(this));this.set=n,this.setState({loaded:!0,id:n.id})}},{key:"componentWillUnmout",value:function(){l.removeSet(this.set)}},{key:"handleLoad",value:function(e){this.props.load&&this.props.load(e)}},{key:"getSet",value:function(){return this.set}},{key:"render",value:function(){return this.state.loaded?u.createElement("div",{ref:"root",className:"raphael-set","data-id":this.state.id},this.props.children):u.createElement("div",{ref:"root",className:"raphael-set","data-id":this.state.id})}}]),t}(u.Component),y=function(e){function t(e){o(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={loaded:!1},n}return i(t,e),p(t,[{key:"componentDidMount",value:function(){var e=c.findDOMNode(this.refs.root),t=e.parentElement.getAttribute("data-id"),n=l.createElement(t,this.props.type,this.props,this.handleLoad.bind(this));this.element=n,this.setState({loaded:!0})}},{key:"componentDidUpdate",value:function(){l.updateElement(this.element,this.props.type,this.props,this.handleUpdate.bind(this))}},{key:"componentWillUnmount",value:function(){l.removeElement(this.element)}},{key:"getElement",value:function(){return this.element}},{key:"handleLoad",value:function(e){this.props.load&&this.props.load(e)}},{key:"handleUpdate",value:function(e){this.props.update&&this.props.update(e)}},{key:"render",value:function(){return this.state.loaded?null:u.createElement("div",{ref:"root",className:"raphael-"+this.props.type})}}]),t}(u.Component),d=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),p(t,[{key:"getElement",value:function(){return this.refs.element.getElement()}},{key:"render",value:function(){return u.createElement(y,s({ref:"element",type:"circle"},this.props))}}]),t}(u.Component);d.propTypes={x:u.PropTypes.number,y:u.PropTypes.number,r:u.PropTypes.number},d.defaultProps={x:0,y:0,r:10};var m=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),p(t,[{key:"getElement",value:function(){return this.refs.element.getElement()}},{key:"render",value:function(){return u.createElement(y,s({ref:"element",type:"ellipse"},this.props))}}]),t}(u.Component);m.propTypes={x:u.PropTypes.number,y:u.PropTypes.number,rx:u.PropTypes.number,ry:u.PropTypes.number},m.defaultProps={x:0,y:0,rx:10,ry:20};var v=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),p(t,[{key:"getElement",value:function(){return this.refs.element.getElement()}},{key:"render",value:function(){return u.createElement(y,s({ref:"element",type:"image"},this.props))}}]),t}(u.Component);v.propTypes={x:u.PropTypes.number,y:u.PropTypes.number,src:u.PropTypes.string,width:u.PropTypes.number,height:u.PropTypes.number},v.defaultProps={x:0,y:0,src:"",width:0,height:0};var b=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),p(t,[{key:"getElement",value:function(){return this.refs.element.getElement()}},{key:"render",value:function(){return u.createElement(y,s({ref:"element",type:"path"},this.props))}}]),t}(u.Component);b.propTypes={d:u.PropTypes.oneOfType([u.PropTypes.string,u.PropTypes.array])},b.defaultProps={d:"M0,0L0,0Z"};var g=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),p(t,[{key:"getElement",value:function(){return this.refs.element.getElement()}},{key:"render",value:function(){return u.createElement(y,s({ref:"element",type:"rect"},this.props))}}]),t}(u.Component);g.propTypes={x:u.PropTypes.number,y:u.PropTypes.number,width:u.PropTypes.number,height:u.PropTypes.number,r:u.PropTypes.number},g.defaultProps={x:0,y:0,width:0,height:0,r:0};var x=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),p(t,[{key:"getElement",value:function(){return this.refs.element.getElement()}},{key:"render",value:function(){return u.createElement(y,s({ref:"element",type:"print"},this.props))}}]),t}(u.Component);x.propTypes={x:u.PropTypes.number,y:u.PropTypes.number,text:u.PropTypes.string,fontFamily:u.PropTypes.string},x.defaultProps={x:0,y:0,text:"",fontFamily:"Arial"};var k=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),p(t,[{key:"getElement",value:function(){return this.refs.element.getElement()}},{key:"render",value:function(){return u.createElement(y,s({ref:"element",type:"text"},this.props))}}]),t}(u.Component);k.propTypes={x:u.PropTypes.number,y:u.PropTypes.number,text:u.PropTypes.string},k.defaultProps={x:0,y:0,text:""};var P=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),p(t,[{key:"getElement",value:function(){return this.refs.path.getElement()}},{key:"render",value:function(){var e=this.props,t=e.x1,n=e.x2,o=e.y1,a=e.y2,i=e.animate,p=e.attr,c=r(e,["x1","x2","y1","y2","animate","attr"]);if(i)if(i.anim)for(var l in i.anim)i.anim[l].x1=i.anim[l].x1||t,i.anim[l].x2=i.anim[l].x2||n,i.anim[l].y1=i.anim[l].y1||o,i.anim[l].y2=i.anim[l].y2||a,i.anim[l].path=["M",i.anim[l].x1,i.anim[l].y1,"L",i.anim[l].x2,i.anim[l].y2];else i.x1=i.x1||t,i.x2=i.x2||n,i.y1=i.y1||o,i.y2=i.y2||a,i.path=["M",i.x1,i.y1,"L",i.x2,i.y2];return p&&(p.x1=p.x1||t,p.x2=p.x2||n,p.y1=p.y1||o,p.y2=p.y2||a,p.path=["M",p.x1,p.y1,"L",p.x2,p.y2]),u.createElement(b,s({ref:"path",d:["M",t,o,"L",n,a],attr:p,animate:i},c))}}]),t}(u.Component);P.propTypes={x1:u.PropTypes.number,y1:u.PropTypes.number,x2:u.PropTypes.number,y2:u.PropTypes.number},P.defaultProps={x1:0,y1:0,x2:0,y2:0},e.exports={Paper:f,Set:h,Element:y,Circle:d,Ellipse:m,Image:v,Path:b,Print:x,Rect:g,Text:k,Line:P}},164:function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=n(162),a={createPaper:function(e,t){var n=t.width,r=t.height,i=o(e,n,r);return i.id=e.id||"paper-"+(new Date).valueOf()+"-"+Math.random().toFixed(10),a.papers.push(i),i},findParentById:function(e){var t=a.papers.filter(function(t,n){return t.id==e});if(t.length>0)return{parent:t[0],paper:t[0]};var n=a.elements.filter(function(t,n){return t.element.id==e});return n.length>0?n[0].element?{parent:n[0].element,paper:n[0].element.paper}:n[0].element:{parent:null,paper:null}},create:function(e,t,n){var r=null,o=a.findParentById(e);if(!o.paper)return o.paper;switch(t){case"set":r=o.paper.set(),r.id="set-"+(new Date).valueOf()+"-"+Math.random().toFixed(10);break;case"circle":var i=n.x,s=n.y,p=n.r;r=o.paper.circle(i,s,p);break;case"ellipse":var i=n.x,s=n.y,u=n.rx,c=n.ry;r=o.paper.ellipse(i,s,u,c);break;case"image":var l=n.src,i=n.x,s=n.y,f=n.width,h=n.height;r=o.paper.image(l,i,s,f,h);break;case"path":var y=n.d;y&&0!=y.length||(y="M0,0L0,0Z"),r=o.paper.path(y);break;case"print":var i=n.x,s=n.y,d=n.text,m=n.fontFamily,v=n.fontWeight,b=n.fontStyle,g=n.fontStretch,x=n.fontSize,k=n.letterSpacing,P=o.paper.getFont(m,v,b,g);r=o.paper.print(i,s,d,P,x,k);break;case"rect":var i=n.x,s=n.y,f=n.width,h=n.height,p=n.r;r=o.paper.rect(i,s,f,h,p);break;case"text":var i=n.x,s=n.y,d=n.text;r=o.paper.text(i,s,d)}return r&&"set"==o.parent.type&&(r.set=o.parent,o.parent.push(r)),a.updateElementProps(r,n),r},createElement:function(e,t,n,r){var o=a.create(e,t,n);return a.elements.push({type:t,props:n,callback:r,element:o}),r&&r(o),o},createSet:function(e,t,n){var r=a.create(e,"set",t);return a.elements.push({type:"set",element:r}),n&&n(r),r},updatePaper:function(e,t){var n=t.width,r=t.height;e.setSize({width:n,height:r})},updateElementProps:function(e,t){if(e){e.matrix=o.matrix(),e.attr("transform","");for(var n in t)switch(n){case"attr":"object"===r(t[n])&&e.attr(t.attr);break;case"animate":"object"===r(t[n])&&e.animate(t.animate);break;case"animateWith":"object"===r(t[n])&&e.animateWith(t.animateWith);break;case"click":"function"==typeof t[n]&&(e.unclick(),e.click(t.click));break;case"data":if("object"===r(t[n])){for(var n in t.data)e.data(n,t.data[n]);e.items=t.data}break;case"dblclick":"function"==typeof t[n]&&(e.undblclick(),e.dblclick(t.dblclick));break;case"drag":"object"===r(t[n])&&(e.undrag(),e.drag(t.drag.move,t.drag.start,t.drag.end,t.drag.mcontext,t.drag.scontext,t.drag.econtext));break;case"glow":"object"===r(t[n])&&e.glow(t.glow);break;case"hover":"object"===r(t[n])&&(e.unhover(),e.hover(t.hover.in,t.hover.out,t.hover.icontext,t.hover.ocontext));break;case"hide":"boolean"==typeof t[n]&&(t.hide?e.hide():e.show());break;case"mousedown":"function"==typeof t[n]&&(e.unmousedown(),e.mousedown(t.mousedown));break;case"mousemove":"function"==typeof t[n]&&(e.unmousemove(),e.mousemove(t.mousemove));break;case"mouseout":"function"==typeof t[n]&&(e.unmouseout(),e.mouseout(t.mouseout));break;case"mouseover":"function"==typeof t[n]&&(e.unmouseover(),e.mouseover(t.mouseover));break;case"mouseup":"function"==typeof t[n]&&(e.unmouseup(),e.mouseup(t.mouseup));break;case"rotate":if("object"===r(t[n])){var a=t.rotate,i=a.deg,s=a.cx,p=a.cy;e.rotate(i,s,p)}break;case"scale":if("object"===r(t[n])){var u=t.scale,c=u.sx,l=u.sy,s=u.cx,p=u.cy;e.scale(c,l,s,p)}break;case"touchcancel":"function"==typeof t[n]&&(e.untouchcancel(),e.touchcancel(t.touchcancel));break;case"touchend":"function"==typeof t[n]&&(e.untouchend(),e.touchend(t.touchend));break;case"touchmove":"function"==typeof t[n]&&(e.untouchmove(),e.touchmove(t.touchmove));break;case"touchstart":"function"==typeof t[n]&&(e.untouchstart(),e.touchstart(t.touchstart));break;case"transform":"object"!==r(t[n])&&"array"!=typeof t[n]||e.transform(t.transform);break;case"translate":"object"===r(t[n])&&e.translate(t.translate.x,t.translate.y)}o.svg&&e.node&&"text"==e.node.nodeName&&e.node.childNodes.length>0&&setTimeout(function(){if(e.node){var t=e.node.getAttribute("y"),n=e.node.childNodes[0].getAttribute("dy");t==n&&e.node.childNodes[0].setAttribute("dy",0)}})}},updateElement:function(e,t,n,r){switch(t){case"circle":var o=n.x,i=n.y,s=n.r;e.attr({cx:o,cy:i,r:s});break;case"ellipse":var o=n.x,i=n.y,p=n.rx,u=n.ry;e.attr({cx:o,cy:i,rx:p,ry:u});break;case"image":var c=n.src,o=n.x,i=n.y,l=n.width,f=n.height;e.attr({src:c,x:o,y:i,width:l,height:f});break;case"path":var h=n.d;h&&0!=h.length||(h="M0,0L0,0Z"),e.attr({path:h});break;case"print":var o=n.x,i=n.y,y=n.text,d=n.fontFamily,m=(n.fontWeight,n.fontStyle,n.fontStretch,n.fontSize);n.letterSpacing;e.attr({x:o,y:i,text:y,"font-family":d,"font-size":m});break;case"rect":var o=n.x,i=n.y,l=n.width,f=n.height,s=n.r;e.attr({x:o,y:i,width:l,height:f,r:s});break;case"text":var o=n.x,i=n.y,y=n.text;e.attr({x:o,y:i,text:y})}return a.updateElementProps(e,n),r&&r(e),e},removePaper:function(e){var t=a.papers.filter(function(t){return t===e});t.length>0&&t[0].remove()},removeSet:function(e){a.removeElement(e)},removeElement:function(e){var t=a.elements.filter(function(t){return t.element===e});t.length>0&&t[0].element.remove()},papers:[],elements:[]};e.exports=a}}); //# sourceMappingURL=app.min.js.map