Touch up comments and formatting

This commit is contained in:
Kevin MacMartin 2015-07-02 14:35:51 -04:00
parent f5abdade9a
commit 09752ed55a

View file

@ -4,7 +4,7 @@ function ContainElement(options) {
var elementWidth = options.width || element.offsetWidth; var elementWidth = options.width || element.offsetWidth;
var elementHeight = options.height || element.offsetHeight; var elementHeight = options.height || element.offsetHeight;
// Apply required attributes to the element and its parents if they aren't already set // Apply required attributes to the element and its parents
element.style.position = 'absolute'; element.style.position = 'absolute';
element.parentElement.style.overflow = 'hidden'; element.parentElement.style.overflow = 'hidden';
if (['relative', 'absolute', 'fixed'].indexOf(window.getComputedStyle(element.parentElement, null).getPropertyValue('position')) === -1) if (['relative', 'absolute', 'fixed'].indexOf(window.getComputedStyle(element.parentElement, null).getPropertyValue('position')) === -1)
@ -30,15 +30,15 @@ function ContainElement(options) {
if (parentWidth < (elementWidth * scaleFactor)) { if (parentWidth < (elementWidth * scaleFactor)) {
switch(options.halign) { switch(options.halign) {
case 'left': case 'left':
// anchor horizontally to the left of the parent element // Anchor horizontally to the left of the parent element
element.style.left = 0 + 'px'; element.style.left = 0 + 'px';
break; break;
case 'right': case 'right':
// anchor horizontally to the right of the parent element // Anchor horizontally to the right of the parent element
element.style.left = (0 - ((elementWidth * scaleFactor) - parentWidth)) + 'px'; element.style.left = (0 - ((elementWidth * scaleFactor) - parentWidth)) + 'px';
break; break;
default: default:
// anchor horizontally to the center of the parent element // Anchor horizontally to the center of the parent element
element.style.left = (0 - (((elementWidth * scaleFactor) - parentWidth) / 2)) + 'px'; element.style.left = (0 - (((elementWidth * scaleFactor) - parentWidth) / 2)) + 'px';
} }
} else { } else {
@ -49,15 +49,15 @@ function ContainElement(options) {
if ((elementHeight * scaleFactor) > parentHeight) { if ((elementHeight * scaleFactor) > parentHeight) {
switch(options.valign) { switch(options.valign) {
case 'top': case 'top':
// anchor vertically to the top of the parent element // Anchor vertically to the top of the parent element
element.style.top = 0 + 'px'; element.style.top = 0 + 'px';
break; break;
case 'bottom': case 'bottom':
// anchor veritcally to the bottom of the parent element // Anchor veritcally to the bottom of the parent element
element.style.top = (0 - ((elementHeight * scaleFactor) - parentHeight)) + 'px'; element.style.top = (0 - ((elementHeight * scaleFactor) - parentHeight)) + 'px';
break; break;
default: default:
// anchor vertically to the center of the parent element // Anchor vertically to the center of the parent element
element.style.top = (0 - (((elementHeight * scaleFactor) - parentHeight) / 2)) + 'px'; element.style.top = (0 - (((elementHeight * scaleFactor) - parentHeight) / 2)) + 'px';
} }
} else { } else {