3
Copyright 2011 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
7
YUI.add('event-resize', function(Y) {
10
* Adds a window resize event that has its behavior normalized to fire at the
11
* end of the resize rather than constantly during the resize.
13
* @submodule event-resize
18
* Old firefox fires the window resize event once when the resize action
19
* finishes, other browsers fire the event periodically during the
20
* resize. This code uses timeout logic to simulate the Firefox
21
* behavior in other browsers.
26
var domEventProxies = Y.Env.evt.dom_wrappers,
28
key = 'event:' + Y.stamp(win) + 'resizenative',
32
Y.Event.define('windowresize', {
34
on: (Y.UA.gecko && Y.UA.gecko < 1.91) ?
35
function (node, sub, notifier) {
36
sub._handle = Y.Event._attach(['resize', function (e) {
38
new Y.DOMEventFacade(e, win, domEventProxies[key]));
39
}], { facade: false });
41
function (node, sub, notifier) {
42
// interval bumped from 40 to 100ms as of 3.4.1
43
var delay = Y.config.windowResizeDelay || 100;
45
sub._handle = Y.Event._attach(['resize', function (e) {
50
sub._timer = Y.later(delay, Y, function () {
52
new Y.DOMEventFacade(e, win, domEventProxies[key]));
54
}], { facade: false });
57
detach: function (node, sub) {
63
// delegate methods not defined because this only works for window
64
// subscriptions, so...yeah.
68
}, '3.4.1' ,{requires:['event-synthetic']});