mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-30 18:35:44 +00:00
collapsibleTabs: Defer DOM changes via requestAnimiationFrame
Widely supported, unprefixed (over 85%) http://caniuse.com/#feat=requestanimationframe Change-Id: I13a73e3ba4f68af86ca77ca8242107ee449b255e
This commit is contained in:
parent
020956d070
commit
f354aafebc
|
@ -2,7 +2,9 @@
|
||||||
* Collapsible tabs jQuery Plugin
|
* Collapsible tabs jQuery Plugin
|
||||||
*/
|
*/
|
||||||
( function ( $ ) {
|
( function ( $ ) {
|
||||||
var rtl = $( 'html' ).attr( 'dir' ) === 'rtl';
|
var rtl = $( 'html' ).attr( 'dir' ) === 'rtl',
|
||||||
|
rAF = window.requestAnimationFrame || setTimeout;
|
||||||
|
|
||||||
$.fn.collapsibleTabs = function ( options ) {
|
$.fn.collapsibleTabs = function ( options ) {
|
||||||
// Merge options into the defaults
|
// Merge options into the defaults
|
||||||
var settings = $.extend( {}, $.collapsibleTabs.defaults, options );
|
var settings = $.extend( {}, $.collapsibleTabs.defaults, options );
|
||||||
|
@ -27,13 +29,13 @@
|
||||||
// if we haven't already bound our resize handler, bind it now
|
// if we haven't already bound our resize handler, bind it now
|
||||||
if ( !$.collapsibleTabs.boundEvent ) {
|
if ( !$.collapsibleTabs.boundEvent ) {
|
||||||
$( window ).on( 'resize', $.debounce( 100, function () {
|
$( window ).on( 'resize', $.debounce( 100, function () {
|
||||||
$.collapsibleTabs.handleResize();
|
rAF( $.collapsibleTabs.handleResize );
|
||||||
} ) );
|
} ) );
|
||||||
$.collapsibleTabs.boundEvent = true;
|
$.collapsibleTabs.boundEvent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// call our resize handler to setup the page
|
// call our resize handler to setup the page
|
||||||
$.collapsibleTabs.handleResize();
|
rAF( $.collapsibleTabs.handleResize );
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
$.collapsibleTabs = {
|
$.collapsibleTabs = {
|
||||||
|
@ -132,7 +134,7 @@
|
||||||
expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) );
|
expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) );
|
||||||
if ( expContainerSettings ) {
|
if ( expContainerSettings ) {
|
||||||
expContainerSettings.shifting = false;
|
expContainerSettings.shifting = false;
|
||||||
$.collapsibleTabs.handleResize();
|
rAF( $.collapsibleTabs.handleResize );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
@ -168,7 +170,7 @@
|
||||||
expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) );
|
expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) );
|
||||||
if ( expContainerSettings ) {
|
if ( expContainerSettings ) {
|
||||||
expContainerSettings.shifting = false;
|
expContainerSettings.shifting = false;
|
||||||
$.collapsibleTabs.handleResize();
|
rAF( $.collapsibleTabs.handleResize );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} )
|
} )
|
||||||
|
|
Loading…
Reference in a new issue