diff --git a/contain-element.min.js b/contain-element.min.js index aa43655..c9073f6 100644 --- a/contain-element.min.js +++ b/contain-element.min.js @@ -1 +1 @@ -function ContainElement(e){function t(){var n=s.parentElement.offsetWidth,a=s.parentElement.offsetHeight;if(n&&a){if(l=n>a/(o*l)*i*l?n/i:a/o,s.style.width=i*l+"px",s.style.height=o*l+"px",i*l>n)switch(e.halign){case"left":s.style.left="0px";break;case"right":s.style.left=0-(i*l-n)+"px";break;default:s.style.left=0-(i*l-n)/2+"px"}else s.style.left="0px";if(o*l>a)switch(e.valign){case"top":s.style.top="0px";break;case"bottom":s.style.top=0-(o*l-a)+"px";break;default:s.style.top=0-(o*l-a)/2+"px"}else s.style.top="0px"}else window.setTimeout(t,30)}var l=1,s=document.getElementById(e.id),i=e.width||s.offsetWidth,o=e.height||s.offsetHeight;"absolute"!=s.style.position&&(s.style.position="absolute"),"hidden"!=s.parentElement.style.overflow&&(s.parentElement.style.overflow="hidden"),-1===["relative","absolute","fixed"].indexOf(s.parentElement.style.position)&&(s.parentElement.style.position="relative"),t(),this.update=t} \ No newline at end of file +function ContainElement(e){function t(){var n=i.parentElement.offsetWidth,a=i.parentElement.offsetHeight;if(n&&a){if(l=n>a/(o*l)*s*l?n/s:a/o,i.style.width=s*l+"px",i.style.height=o*l+"px",s*l>n)switch(e.halign){case"left":i.style.left="0px";break;case"right":i.style.left=0-(s*l-n)+"px";break;default:i.style.left=0-(s*l-n)/2+"px"}else i.style.left="0px";if(o*l>a)switch(e.valign){case"top":i.style.top="0px";break;case"bottom":i.style.top=0-(o*l-a)+"px";break;default:i.style.top=0-(o*l-a)/2+"px"}else i.style.top="0px"}else window.setTimeout(t,30)}var l=1,i=document.getElementById(e.id),s=e.width||i.offsetWidth,o=e.height||i.offsetHeight;i.style.position="absolute",i.parentElement.style.overflow="hidden",-1===["relative","absolute","fixed"].indexOf(window.getComputedStyle(i.parentElement,null).getPropertyValue("position"))&&(i.parentElement.style.position="relative"),t(),this.update=t} \ No newline at end of file