UNPKG

bodymovin

Version:

After Effects plugin for exporting animations to SVG + JavaScript or canvas + JavaScript

46 lines (39 loc) 1.55 kB
function IImageElement(data,parentContainer,globalData,comp,placeholder){ this.assetData = globalData.getAssetData(data.refId); this._parent.constructor.call(this,data,parentContainer,globalData,comp,placeholder); } createElement(SVGBaseElement, IImageElement); IImageElement.prototype.createElements = function(){ var assetPath = this.globalData.getAssetsPath(this.assetData); this._parent.createElements.call(this); this.innerElem = document.createElementNS(svgNS,'image'); this.innerElem.setAttribute('width',this.assetData.w+"px"); this.innerElem.setAttribute('height',this.assetData.h+"px"); this.innerElem.setAttribute('preserveAspectRatio','xMidYMid slice'); this.innerElem.setAttributeNS('http://www.w3.org/1999/xlink','href',assetPath); this.maskedElement = this.innerElem; this.layerElement.appendChild(this.innerElem); if(this.data.ln){ this.layerElement.setAttribute('id',this.data.ln); } if(this.data.cl){ this.layerElement.setAttribute('class',this.data.cl); } }; IImageElement.prototype.renderFrame = function(parentMatrix){ var renderParent = this._parent.renderFrame.call(this,parentMatrix); if(renderParent===false){ this.hide(); return; } if(this.hidden){ this.show(); } if(this.firstFrame){ this.firstFrame = false; } }; IImageElement.prototype.destroy = function(){ this._parent.destroy.call(this._parent); this.innerElem = null; };