Hilo/build/cmd/hilo/renderer/DOMRenderer.min.js
2022-06-29 10:45:02 +08:00

6 lines
1.9 KiB
JavaScript

/**
* hilojs 2.0.3 for cmd
* Copyright 2016 alibaba.com
* Licensed under the MIT License
*/
define(function(e,t,a){var i=e("hilo/core/Class"),r=e("hilo/core/Hilo"),n=e("hilo/renderer/Renderer"),l=e("hilo/view/Drawable"),o=function(){function e(e,t){var a=e.tagName||"div",i=t.image,n=e.width||i&&i.width,l=e.height||i&&i.height,o=r.createElement(a),d=o.style;if(e.id&&(o.id=e.id),d.position="absolute",d.left=(e.left||0)+"px",d.top=(e.top||0)+"px",d.width=n+"px",d.height=l+"px","canvas"==a){if(o.width=n,o.height=l,i){var h=o.getContext("2d"),s=t.rect||[0,0,n,l];h.drawImage(i,s[0],s[1],s[2],s[3],e.x||0,e.y||0,e.width||s[2],e.height||s[3])}}else if(d.opacity=void 0!=e.alpha?e.alpha:1,(e===this.stage||e.clipChildren)&&(d.overflow="hidden"),i&&i.src){d.backgroundImage="url("+i.src+")";var c=e.rectX||0,p=e.rectY||0;d.backgroundPosition=-c+"px "+-p+"px"}return o}return i.create({Extends:n,constructor:function(e){o.superclass.constructor.call(this,e)},renderType:"dom",startDraw:function(t){var a=t.drawable=t.drawable||new l;return a.domElement=a.domElement||e(t,a),!0},draw:function(e){var t=e.parent,a=e.drawable.domElement,i=a.parentNode;if(t){var r=t.drawable.domElement;if(r!=i&&r.appendChild(a),!e.width&&!e.height){var n=e.drawable.rect;n&&(n[2]||n[3])&&(e.width=n[2],e.height=n[3])}}else e!==this.stage||i||(a.style.overflow="hidden",this.canvas.appendChild(a))},transform:function(e){if(r.setElementStyleByView(e),e===this.stage){var t=this.canvas.style,a=e._scaleX,i=e._scaleY,n=e.scaleX,l=e.scaleY;(!a&&1!=n||a&&a!=n)&&(e._scaleX=n,t.width=n*e.width+"px"),(!i&&1!=l||i&&i!=l)&&(e._scaleY=l,t.height=l*e.height+"px")}},remove:function(e){var t=e.drawable,a=t&&t.domElement;if(a){var i=a.parentNode;i&&i.removeChild(a)}},hide:function(e){var t=e.drawable&&e.drawable.domElement;t&&(t.style.display="none")},resize:function(e,t){var a=this.canvas.style;a.width=e+"px",a.height=t+"px","absolute"!=a.position&&(a.position="relative")}})}();return o});