can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[livejournal] r21671: LJSUP-11421: center lj.modalWindow on pa...

Committer: dpetrov
LJSUP-11421: center lj.modalWindow on page scroll
U   trunk/htdocs/js/jquery/jquery.lj.modalWindow.js
Modified: trunk/htdocs/js/jquery/jquery.lj.modalWindow.js
===================================================================
--- trunk/htdocs/js/jquery/jquery.lj.modalWindow.js	2012-04-06 12:15:32 UTC (rev 21670)
+++ trunk/htdocs/js/jquery/jquery.lj.modalWindow.js	2012-04-06 12:20:44 UTC (rev 21671)
@@ -48,6 +48,7 @@
 		 * @private
 		 */
 		_create: function () {
+			this._visible = false;
 			this._makeNodes();
 		},
 
@@ -82,6 +83,12 @@
 				}
 			}
 
+			function onScroll(evt) {
+				if (!this._visible) { return; }
+
+				this.updatePosition();
+			}
+
 			return function () {
 				var options = this.options;
 				var selectors = options.selectors;
@@ -90,6 +97,7 @@
 					.delegate(selectors.closeBtn, 'click', this, onClose);
 
 				this._faderNode.bind('click', this, onClose);
+				$(window).scroll(LJ.throttle(onScroll.bind(this), 200));
 
 				$(document).bind('keydown', this, onCloseEsc);
 			}
@@ -137,6 +145,7 @@
 				this._contentNode.css('height', this.options.height);
 			}
 
+			this._visible = true;
 			this.updatePosition();
 
 			$(document.body)
@@ -151,6 +160,7 @@
 		 * @function
 		 */
 		hide: function () {
+			this._visible = false;
 			this._faderNode.detach();
 			this._popupNode.detach();
 			this._trigger('hide');
@@ -172,4 +182,4 @@
  * @event
  * @param {Object} evt jQuery event object
  * @description The event window is hide {@link $.lj.modalWindow#hide}.
- */
\ No newline at end of file
+ */

Tags: can3p, dpetrov, js, livejournal
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments