当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。