search

goog.dom.ViewportSizeMonitor

Provided By
Extends
All Implemented Interfaces

This class can be used to monitor changes in the viewport size. Instances dispatch a goog.events.EventType.RESIZE event when the viewport size changes. Handlers can call goog.dom.ViewportSizeMonitor#getSize to get the new viewport size.

Use this class if you want to execute resize/reflow logic each time the user resizes the browser window. This class is guaranteed to only dispatch RESIZE events when the pixel dimensions of the viewport change. (Internet Explorer fires resize events if any element on the page is resized, even if the viewport dimensions are unchanged, which can lead to infinite resize loops.)

Example usage:

    var vsm = new goog.dom.ViewportSizeMonitor();
    goog.events.listen(vsm, goog.events.EventType.RESIZE, function(e) {
      alert('Viewport size changed to ' + vsm.getSize());
    });
  

Manually verified on IE6, IE7, FF2, Opera 11, Safari 4 and Chrome.

new ViewportSizeMonitor( opt_window )

Parameters
opt_window(Window|null)=

The window to monitor; defaults to the window in which this code is executing.

Instance Methods

Instance Properties

Static Functions