Due to jQuery propagating events, the window resize event could be triggered by a bubbled event.

See https://bugs.jquery.com/ticket/9841. In our case, the OutputArea was triggering a ‘resize’ event on its element, which was bubbling up and causing this handler to execute every time an output was appended. This was a pretty big drain on output areas that quickly changed (like for interact widgets), presumably since this function involves a DOM read to get heights.
pull/1985/head
Jason Grout 9 years ago
parent 0c5613b13a
commit e909afc93a

@ -52,9 +52,13 @@ define([
this._resize_site();
};
Page.prototype._resize_site = function() {
Page.prototype._resize_site = function(e) {
// Update the site's size.
$('div#site').height($(window).height() - $('#header').height());
// only trigger if the event actually is the window's, not bubbling up.
// See https://bugs.jquery.com/ticket/9841#comment:8
if (!e.target.tagName) {
$('div#site').height($(window).height() - $('#header').height());
}
};
return {'Page': Page};

Loading…
Cancel
Save