Releases: WilliamsNY/contain-element
Releases · WilliamsNY/contain-element
Version 1.0.0 (Initial Release)
This is the initial release (v1.0.0) for contain-element!
Features
- Pure JavaScript with no dependencies
- Configures the horizontal and vertical alignment of the contained element
- Can detect the native size or have it specified at runtime
- Includes function to update the size and position
Usage
window.onload = function() {
var contain = new ContainElement({
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: center)
halign: 'left' // (optional) horizontal alignment: left|right (unset: center)
});
// (example) update the size and positioning on window resize
window.onresize = contain.update;
// (example) update the size and positioning on orientation change
screen.addEventListener('orientationchange', contain.update);
};