# Yahoo! UI Library

### event 3.0.0b1

Yahoo! UI Library > event > resize-window.js (source view)
Search:
Filters
Show Private Show Protected Show Deprecated

    (function() {

    var detachHandle,

        timerHandle,

        CE_NAME = 'window:resize',

        handler = function(e) {

            if (Y.UA.gecko) {

                Y.fire(CE_NAME, e);

            } else {

                if (timerHandle) {
                    timerHandle.cancel();
                }

                timerHandle = Y.later(Y.config.windowResizeDelay || 40, Y, function() {
                    Y.fire(CE_NAME, e);
                });
            }

        };

    /**
     * Firefox fires the window resize event once when the resize action
     * finishes, other browsers fire the event periodically during the
     * resize.  This code uses timeout logic to simulate the Firefox
     * behavior in other browsers.
     * @event windowresize
     * @for YUI
     */
    Y.Env.evt.plugins.windowresize = {

        on: function(type, fn) {

            // check for single window listener and add if needed
            if (!detachHandle) {
                detachHandle = Y.Event._attach(['resize', handler]);
            }

            var a = Y.Array(arguments, 0, true);
            a[0] = CE_NAME;

            return Y.on.apply(Y, a);
        }
    };

    })();

Copyright © 2009 Yahoo! Inc. All rights reserved.