From 9e37412a2bb7710a898c0732ca46f33a4b608afb Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sat, 7 Nov 2009 23:02:46 -0800 Subject: Use window.scrollX and window.scrollY instead of document.scrollLeft/top. It's easier to use on webkit and is not buggy.--- background_page.html | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'background_page.html') diff --git a/background_page.html b/background_page.html index b18c87be..5ad8c2e6 100644 --- a/background_page.html +++ b/background_page.html @@ -10,7 +10,7 @@ // Event handlers var selectionChangedHandlers = []; - var getScrollPositionHandlers = {}; // tabId -> function (tab, scrollTop, scrollLeft) + var getScrollPositionHandlers = {}; // tabId -> function (tab, scrollX, scrollY); var tabLoadedHandlers = {}; // tabId -> function () chrome.extension.onConnect.addListener(function(port, name) { @@ -26,7 +26,7 @@ // Delete first to be sure there's no circular events. var toCall = getScrollPositionHandlers[args.currentTab.id]; delete getScrollPositionHandlers[args.currentTab.id]; - toCall(args.currentTab, args.scrollTop, args.scrollLeft); + toCall(args.currentTab, args.scrollX, args.scrollY); } } @@ -52,7 +52,7 @@ } // Returns the currently selected tab along with scroll coordinates. Pass in a callback of the form: - // function (tab, scrollTop, scrollLeft) { .. } + // function (tab, scrollX, scrollY) { .. } function getCurrentTabWithScrollPosition(callback) { chrome.tabs.getSelected(null, function (tab) { getScrollPositionHandlers[tab.id] = callback; @@ -67,9 +67,8 @@ } function removeTab(callback) { - getCurrentTabWithScrollPosition(function(tab, scrollTop, scrollLeft) { - tabQueue.push({ tabUrl: tab.url, scrollTop: scrollTop, - scrollLeft: scrollLeft }); + getCurrentTabWithScrollPosition(function(tab, scrollX, scrollY) { + tabQueue.push({ tabUrl: tab.url, scrollX: scrollX, scrollY: scrollY }); chrome.tabs.remove(tab.id); // We can't just call the callback here because we actually need to wait // for the selection to change to consider this action done. @@ -87,7 +86,7 @@ chrome.tabs.create({ url: tabQueueEntry.tabUrl }, function (tab) { tabLoadedHandlers[tab.id] = function () { var scrollPort = chrome.tabs.connect(tab.id, {name: "setScrollPosition"}); - scrollPort.postMessage({ scrollTop: tabQueueEntry.scrollTop, scrollLeft: tabQueueEntry.scrollLeft }); + scrollPort.postMessage({ scrollX: tabQueueEntry.scrollX, scrollY: tabQueueEntry.scrollY }); }; callback(); -- cgit v1.2.3