當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


JQuery Mobile throttledresize用法及代碼示例

throttledresize event

添加的版本:1.0

說明:限製處理程序對調整大小事件的執行速率。

  • jQuery( ".selector" ).on( "throttledresize", function( event ) { ... } )

jQuery Mobile throttledresize 事件是一個特殊事件,可防止瀏覽器在調整大小時運行連續回調。 throttledresize 在內部用於 Internet Explorer 等瀏覽器的方向更改。 throttledresize 確保暫停事件將在超時後執行,因此在調整大小完成後取決於最終條件的邏輯仍將正確執行。

如果本機不支持orientationchange,則會觸發throttledresize 事件。

當瀏覽器窗口從以下位置調整大小時觸發此事件:

  1. 方向改變(支持方向的設備);
  2. 複製空間/縱向變化的尺寸比變化(調整桌麵瀏覽器的大小)。

這個插件擴展了 jQuery 的內置方法。如果沒有加載 jQuery Mobile,調用 .throttledresize() 方法可能不會直接失敗,因為該方法仍然存在。但是,不會發生預期的行為。

var count = 0;
$(function() {
  // Bind an event handler to window throttledresize event that, when triggered,
  // passes a reference of itself that is accessible by the callback function.
  $( window ).on( "throttledresize", throttledresizeHandler );
 
  function throttledresizeHandler( event ) {
    $( "#output-text" ).html( "Event Count: " + ++count );
  }
 
  // You can also manually force this event to fire.
  $( window ).trigger( "throttledresize" );
});

從您的定向設備訪問它以查看它的實際效果!

效果演示

相關用法


注:本文由純淨天空篩選整理自jquerymobile.com大神的英文原創作品 throttledresize。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。