HOME > > > > >

jQuery.fx.off

アニメーションを無効にする。アニメーション(遷移)の無効化であって結果は変わらない。

サンプル

実行結果

execute toggle fx
アニメーション ON

Javascript

  1. $('#sample-1').on('click', '.cq-btn', function (e) {
  2.     switch ($(e.target).text()) {
  3.         case 'execute':
  4.             $('#sample-1 .photo').toggle('slow');
  5.             break;
  6.  
  7.         case 'toggle fx':
  8.             if ($.fx.off === true) {
  9.                 $('#mode-text').text('アニメーション ON');
  10.             } else {
  11.                 $('#mode-text').text('アニメーション OFF');
  12.             }
  13.             $.fx.off = !$.fx.off;
  14.             break;
  15.     }
  16. });

HTML

  1. <div id="sample-1">
  2.   <img src="/resource/images/photos/2.jpg" alt="" class="photo">
  3.   <div>
  4.     <span class="cq-btn m-primary" id="execute-1">execute</span>
  5.     <span class="cq-btn m-success" id="execute-2">toggle fx</span>
  6.   </div>
  7.   <span id="mode-text">アニメーション ON</span>
  8. </div>