Skip to content

Latest commit

 

History

History
46 lines (38 loc) · 1.29 KB

no-animate-toggle.md

File metadata and controls

46 lines (38 loc) · 1.29 KB

no-animate-toggle

Disallows the duration argument when using the .show, .hide & .toggle methods. Prefer CSS transitions.

📋 This rule is enabled in plugin:no-jquery/slim.

Rule details

❌ Examples of incorrect code:

$( 'div' ).show( 'fast' );
$div.show( 500 );
$( 'div' ).first().show( { duration: 'slow' } );
$( 'div' ).append( $( 'input' ).show( { duration: 'slow' } ) );
$( 'div' ).hide( 'fast' );
$div.hide( 500 );
$( 'div' ).first().hide( { duration: 'slow' } );
$( 'div' ).append( $( 'input' ).hide( { duration: 'slow' } ) );
$( 'div' ).toggle( 'fast' );
$div.toggle( 500 );
$( 'div' ).first().toggle( { duration: 'slow' } );
$( 'div' ).append( $( 'input' ).toggle( { duration: 'slow' } ) );

✔️ Examples of correct code:

$div.show();
$( 'div' ).show();
$( 'div' ).show;
$.show( 'fast' );
$div.toggle();
$( 'div' ).toggle();
$( 'div' ).toggle;
$div.toggle( false );
$div.toggle( true );
$div.toggle( variableCouldBeBoolean );
$div.toggle( !!'0' );
$div.toggle( getBoolean() );

Resources