From 5226ead17de79e094290efd2142fe93b27017ba9 Mon Sep 17 00:00:00 2001 From: Luke Evers Date: Wed, 1 Jul 2015 14:05:48 -0400 Subject: [PATCH] Use `center` instead of `middle` everywhere. With CSS background positioning, the word `center` is generally used. This is pretty much that, but for any element. --- README.md | 6 +++--- contain-element.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bacc9c8..d6802bf 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A JavaScript plugin to contain an element within its parent element. ## Description -The plugin scales an element to the minimum size required for it to be completely contained within its parent, and retains its original aspect ratio by cropping portions that don't fit based on its vertical and horizontal alignment (by default both are set to: `middle`). +The plugin scales an element to the minimum size required for it to be completely contained within its parent, and retains its original aspect ratio by cropping portions that don't fit based on its vertical and horizontal alignment (by default both are set to: `center`). [Demo](http://williamsny.github.io/contain-element/) @@ -23,8 +23,8 @@ window.onload = function() { id: 'element', // the id of the element to be contained width: '100', // (optional) element width in pixels (unset: element width) height: '100', // (optional) element height in pixels (unset: element height) - valign: 'top', // (optional) vertical alignment: top|bottom (unset: middle) - halign: 'left' // (optional) horizontal alignment: left|right (unset: middle) + valign: 'top', // (optional) vertical alignment: top|bottom (unset: center) + halign: 'left' // (optional) horizontal alignment: left|right (unset: center) }); // (example) update the size and positioning on window resize diff --git a/contain-element.js b/contain-element.js index cd61348..30df6fe 100644 --- a/contain-element.js +++ b/contain-element.js @@ -40,7 +40,7 @@ function ContainElement(options) { element.style.left = (0 - ((elementWidth * scaleFactor) - parentWidth)) + 'px'; break; default: - // anchor horizontally to the middle of the parent element + // anchor horizontally to the center of the parent element element.style.left = (0 - (((elementWidth * scaleFactor) - parentWidth) / 2 )) + 'px'; } } else { @@ -59,7 +59,7 @@ function ContainElement(options) { element.style.top = (0 - ((elementHeight * scaleFactor) - parentHeight)) + 'px'; break; default: - // anchor vertically to the middle of the parent element + // anchor vertically to the center of the parent element element.style.top = (0 - (((elementHeight * scaleFactor) - parentHeight) / 2 )) + 'px'; } } else {