Skip to content

Commit 2f6959d

Browse files
JeanRemiDelteilmarcj
authored andcommitted
Fix ResizeSensor to fire when used in a CustomElement (marcj#206)
Calling Reset() just after initialization does not fire the 'scroll' events. Instead, call it in the next frame. This also works with native elements and simple DOM.
1 parent 072a3fc commit 2f6959d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ResizeSensor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@
166166
shrink.scrollTop = 100000;
167167
};
168168

169-
reset();
170-
171169
var onResized = function() {
172170
rafId = 0;
173171

@@ -204,6 +202,9 @@
204202

205203
addEvent(expand, 'scroll', onScroll);
206204
addEvent(shrink, 'scroll', onScroll);
205+
206+
// Fix for custom Elements
207+
requestAnimationFrame(reset);
207208
}
208209

209210
forEachElement(element, function(elem){

0 commit comments

Comments
 (0)