Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/ResizeSensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
* @constructor
*/
var ResizeSensor = function(element, callback) {

var observer;

/**
*
* @constructor
Expand Down Expand Up @@ -147,7 +147,8 @@
'</div>';
element.appendChild(element.resizeSensor);

var position = window.getComputedStyle(element).getPropertyValue('position');
var computedStyle = window.getComputedStyle(element);
var position = computedStyle ? computedStyle.getPropertyValue('position') : null;
if ('absolute' !== position && 'relative' !== position && 'fixed' !== position) {
element.style.position = 'relative';
}
Expand All @@ -161,15 +162,15 @@
var lastWidth = size.width;
var lastHeight = size.height;
var initialHiddenCheck = true, resetRAF_id;


var resetExpandShrink = function () {
expandChild.style.width = '100000px';
expandChild.style.height = '100000px';

expand.scrollLeft = 100000;
expand.scrollTop = 100000;

shrink.scrollLeft = 100000;
shrink.scrollTop = 100000;
};
Expand All @@ -186,11 +187,11 @@
if (!resetRAF_id){
resetRAF_id = requestAnimationFrame(function(){
resetRAF_id = 0;

reset();
});
}

return;
} else {
// Stop checking
Expand Down Expand Up @@ -236,11 +237,11 @@

addEvent(expand, 'scroll', onScroll);
addEvent(shrink, 'scroll', onScroll);

// Fix for custom Elements
requestAnimationFrame(reset);
}

if (typeof ResizeObserver !== "undefined") {
observer = new ResizeObserver(function(element){
forEachElement(element, function (elem) {
Expand Down