|
83 | 83 | * @constructor |
84 | 84 | */ |
85 | 85 | var ResizeSensor = function(element, callback) { |
86 | | - |
| 86 | + |
87 | 87 | var observer; |
88 | | - |
| 88 | + |
89 | 89 | /** |
90 | 90 | * |
91 | 91 | * @constructor |
|
147 | 147 | '</div>'; |
148 | 148 | element.appendChild(element.resizeSensor); |
149 | 149 |
|
150 | | - var position = window.getComputedStyle(element).getPropertyValue('position'); |
| 150 | + var computedStyle = window.getComputedStyle(element); |
| 151 | + var position = computedStyle ? computedStyle.getPropertyValue('position') : null; |
151 | 152 | if ('absolute' !== position && 'relative' !== position && 'fixed' !== position) { |
152 | 153 | element.style.position = 'relative'; |
153 | 154 | } |
|
161 | 162 | var lastWidth = size.width; |
162 | 163 | var lastHeight = size.height; |
163 | 164 | var initialHiddenCheck = true, resetRAF_id; |
164 | | - |
165 | | - |
| 165 | + |
| 166 | + |
166 | 167 | var resetExpandShrink = function () { |
167 | 168 | expandChild.style.width = '100000px'; |
168 | 169 | expandChild.style.height = '100000px'; |
169 | | - |
| 170 | + |
170 | 171 | expand.scrollLeft = 100000; |
171 | 172 | expand.scrollTop = 100000; |
172 | | - |
| 173 | + |
173 | 174 | shrink.scrollLeft = 100000; |
174 | 175 | shrink.scrollTop = 100000; |
175 | 176 | }; |
|
186 | 187 | if (!resetRAF_id){ |
187 | 188 | resetRAF_id = requestAnimationFrame(function(){ |
188 | 189 | resetRAF_id = 0; |
189 | | - |
| 190 | + |
190 | 191 | reset(); |
191 | 192 | }); |
192 | 193 | } |
193 | | - |
| 194 | + |
194 | 195 | return; |
195 | 196 | } else { |
196 | 197 | // Stop checking |
|
236 | 237 |
|
237 | 238 | addEvent(expand, 'scroll', onScroll); |
238 | 239 | addEvent(shrink, 'scroll', onScroll); |
239 | | - |
| 240 | + |
240 | 241 | // Fix for custom Elements |
241 | 242 | requestAnimationFrame(reset); |
242 | 243 | } |
243 | | - |
| 244 | + |
244 | 245 | if (typeof ResizeObserver !== "undefined") { |
245 | 246 | observer = new ResizeObserver(function(element){ |
246 | 247 | forEachElement(element, function (elem) { |
|
0 commit comments