From c6439f204eb0911381fb479b4a39c211e6ea7492 Mon Sep 17 00:00:00 2001 From: Tim Reynolds Date: Fri, 4 Nov 2011 07:02:27 -0700 Subject: [PATCH 1/2] Added scroll method to class to get around error with stopObserving in Prototype.js version 1.6.0.3. Should be more compatible with other libraries now by not removing their scroll event handlers. --- modalbox.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modalbox.js b/modalbox.js index 611c226..68a2a91 100644 --- a/modalbox.js +++ b/modalbox.js @@ -85,10 +85,7 @@ Modalbox.Methods = { $('MB_window').setStyle({top:scrollOffsets[1] + 'px'}); } - Event.observe(window, 'scroll', function() { - scrollOffsets = document.viewport.getScrollOffsets(); - $('MB_window').setStyle({top:scrollOffsets[1] + 'px'}); - }); + Event.observe(window, 'scroll', this.scroll); // Initial scrolling position of the window. To be used for remove scrolling effect during ModalBox appearing this.initScrollX = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft; @@ -102,6 +99,11 @@ Modalbox.Methods = { this.initialized = true; // Mark as initialized }, + + scroll: function() { + scrollOffsets = document.viewport.getScrollOffsets(); + $('MB_window').setStyle({top:scrollOffsets[1] + 'px'}); + } show: function(content, options) { if (!this.initialized) this._init(options); // Check if MB is already initialized @@ -139,7 +141,7 @@ Modalbox.Methods = { this.MBwindow.hide(); this._deinit(); } - Event.stopObserving(window, 'scroll'); + Event.stopObserving(window, 'scroll', scroll); } else { throw("Modalbox is not initialized."); } From c3a5282e11547f0e149c646f7950208d5113b9aa Mon Sep 17 00:00:00 2001 From: Tim Reynolds Date: Fri, 4 Nov 2011 07:05:42 -0700 Subject: [PATCH 2/2] Missing a 'this.' on one line. --- modalbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modalbox.js b/modalbox.js index 68a2a91..e662fc2 100644 --- a/modalbox.js +++ b/modalbox.js @@ -141,7 +141,7 @@ Modalbox.Methods = { this.MBwindow.hide(); this._deinit(); } - Event.stopObserving(window, 'scroll', scroll); + Event.stopObserving(window, 'scroll', this.scroll); } else { throw("Modalbox is not initialized."); }