mirror of
https://github.com/WilliamsNY/contain-element.git
synced 2024-11-21 13:52:32 -05:00
Touch up comments and formatting
This commit is contained in:
parent
f5abdade9a
commit
09752ed55a
1 changed files with 10 additions and 10 deletions
|
@ -4,7 +4,7 @@ function ContainElement(options) {
|
|||
var elementWidth = options.width || element.offsetWidth;
|
||||
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.parentElement.style.overflow = 'hidden';
|
||||
if (['relative', 'absolute', 'fixed'].indexOf(window.getComputedStyle(element.parentElement, null).getPropertyValue('position')) === -1)
|
||||
|
@ -30,15 +30,15 @@ function ContainElement(options) {
|
|||
if (parentWidth < (elementWidth * scaleFactor)) {
|
||||
switch(options.halign) {
|
||||
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';
|
||||
break;
|
||||
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';
|
||||
break;
|
||||
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';
|
||||
}
|
||||
} else {
|
||||
|
@ -49,15 +49,15 @@ function ContainElement(options) {
|
|||
if ((elementHeight * scaleFactor) > parentHeight) {
|
||||
switch(options.valign) {
|
||||
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';
|
||||
break;
|
||||
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';
|
||||
break;
|
||||
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';
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue