7 * Anchors this window to another element and realigns it when the window is resized or scrolled.
8 * @param {Mixed} element The element to align to.
9 * @param {String} position The position to align to (see {@link Ext.core.Element#alignTo} for more details)
10 * @param {Array} offsets (optional) Offset the positioning by [x, y]
11 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
12 * is a number, it is used as the buffer delay (defaults to 50ms).
13 * @return {Ext.window.Window} this
15 anchorTo: function(el, alignment, offsets, monitorScroll) {
23 Ext.EventManager.onWindowResize(this.doAnchor, this);
24 var tm = typeof monitorScroll;
25 if (tm != 'undefined') {
26 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
28 buffer: tm == 'number' ? monitorScroll: 50
31 return this.doAnchor();
35 * Performs the anchor, using the saved anchorTarget property.
36 * @return {Ext.window.Window} this
39 doAnchor: function() {
40 var o = this.anchorTarget;
41 this.alignTo(o.el, o.alignment, o.offsets);
46 * Removes any existing anchor from this window. See {@link #anchorTo}.
47 * @return {Ext.window.Window} this
49 clearAnchor: function() {
50 if (this.anchorTarget) {
51 Ext.EventManager.removeResizeListener(this.doAnchor, this);
52 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
53 delete this.anchorTarget;