- if(this.doAnchor){
- Ext.EventManager.removeResizeListener(this.doAnchor, this);
- Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
- }
- this.doAnchor = function(){
- this.alignTo(el, alignment, offsets);
- };
- Ext.EventManager.onWindowResize(this.doAnchor, this);
-
- var tm = typeof monitorScroll;
- if(tm != 'undefined'){
- Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
- {buffer: tm == 'number' ? monitorScroll : 50});
- }
- return this;
+ this.clearAnchor();
+ this.anchorTarget = {
+ el: el,
+ alignment: alignment,
+ offsets: offsets
+ };
+
+ Ext.EventManager.onWindowResize(this.doAnchor, this);
+ var tm = typeof monitorScroll;
+ if(tm != 'undefined'){
+ Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
+ {buffer: tm == 'number' ? monitorScroll : 50});
+ }
+ return this.doAnchor();
+ },
+
+ /**
+ * Performs the anchor, using the saved anchorTarget property.
+ * @return {Ext.Window} this
+ * @private
+ */
+ doAnchor : function(){
+ var o = this.anchorTarget;
+ this.alignTo(o.el, o.alignment, o.offsets);
+ return this;
+ },
+
+ <div id="method-Ext.Window-clearAnchor"></div>/**
+ * Removes any existing anchor from this window. See {@link #anchorTo}.
+ * @return {Ext.Window} this
+ */
+ clearAnchor : function(){
+ if(this.anchorTarget){
+ Ext.EventManager.removeResizeListener(this.doAnchor, this);
+ Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
+ delete this.anchorTarget;
+ }
+ return this;