[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/event-resize/ -> event-resize.js (source)

   1  /*
   2  YUI 3.17.2 (build 9c3c78e)
   3  Copyright 2014 Yahoo! Inc. All rights reserved.
   4  Licensed under the BSD License.
   5  http://yuilibrary.com/license/
   6  */
   7  
   8  YUI.add('event-resize', function (Y, NAME) {
   9  
  10  /**
  11   * Adds a window resize event that has its behavior normalized to fire at the
  12   * end of the resize rather than constantly during the resize.
  13   * @module event
  14   * @submodule event-resize
  15   */
  16  
  17  
  18  /**
  19   * Old firefox fires the window resize event once when the resize action
  20   * finishes, other browsers fire the event periodically during the
  21   * resize.  This code uses timeout logic to simulate the Firefox
  22   * behavior in other browsers.
  23   * @event windowresize
  24   * @for YUI
  25   */
  26  Y.Event.define('windowresize', {
  27  
  28      on: (Y.UA.gecko && Y.UA.gecko < 1.91) ?
  29          function (node, sub, notifier) {
  30              sub._handle = Y.Event.attach('resize', function (e) {
  31                  notifier.fire(e);
  32              });
  33          } :
  34          function (node, sub, notifier) {
  35              // interval bumped from 40 to 100ms as of 3.4.1
  36              var delay = Y.config.windowResizeDelay || 100;
  37  
  38              sub._handle = Y.Event.attach('resize', function (e) {
  39                  if (sub._timer) {
  40                      sub._timer.cancel();
  41                  }
  42  
  43                  sub._timer = Y.later(delay, Y, function () {
  44                      notifier.fire(e);
  45                  });
  46              });
  47          },
  48  
  49      detach: function (node, sub) {
  50          if (sub._timer) {
  51              sub._timer.cancel();
  52          }
  53          sub._handle.detach();
  54      }
  55      // delegate methods not defined because this only works for window
  56      // subscriptions, so...yeah.
  57  });
  58  
  59  
  60  }, '3.17.2', {"requires": ["node-base", "event-synthetic"]});


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1