mirror of
https://github.com/WilliamsNY/contain-element.git
synced 2024-11-21 22:02:31 -05:00
Fix parent position check before applying relative style if none of the valid positions are used
This commit is contained in:
parent
ae68564e88
commit
fc9f124c7c
1 changed files with 3 additions and 5 deletions
|
@ -5,11 +5,9 @@ function ContainElement(options) {
|
||||||
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 if they aren't already set
|
||||||
if (element.style.position != 'absolute')
|
|
||||||
element.style.position = 'absolute';
|
element.style.position = 'absolute';
|
||||||
if (element.parentElement.style.overflow != 'hidden')
|
|
||||||
element.parentElement.style.overflow = 'hidden';
|
element.parentElement.style.overflow = 'hidden';
|
||||||
if (['relative', 'absolute', 'fixed'].indexOf(element.parentElement.style.position) === -1)
|
if (['relative', 'absolute', 'fixed'].indexOf(window.getComputedStyle(element.parentElement,null).getPropertyValue('position')) === -1)
|
||||||
element.parentElement.style.position = 'relative';
|
element.parentElement.style.position = 'relative';
|
||||||
|
|
||||||
function updateContain() {
|
function updateContain() {
|
||||||
|
|
Loading…
Reference in a new issue