diff options
| author | Phil Crosby | 2009-11-07 23:02:46 -0800 |
|---|---|---|
| committer | Phil Crosby | 2009-11-07 23:03:16 -0800 |
| commit | 9e37412a2bb7710a898c0732ca46f33a4b608afb (patch) | |
| tree | ce44f98c80aa2b02762caea45262ebd78feed42a /background_page.html | |
| parent | a996c5a370f1790714f3202320002c60fe82c61c (diff) | |
| download | vimium-9e37412a2bb7710a898c0732ca46f33a4b608afb.tar.bz2 | |
Use window.scrollX and window.scrollY instead of document.scrollLeft/top.
It's easier to use on webkit and is not buggy.
Diffstat (limited to 'background_page.html')
| -rw-r--r-- | background_page.html | 13 |
1 files changed, 6 insertions, 7 deletions
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(); |
